Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA Mapping Exception

 
Joe Harry
Ranch Hand
Posts: 10079
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have an Entity mapping defined in my xml configuration that maps to a table. In that table, one of the column is of char datatype in Oracle. When I try to fetch them, I get the following error:



In my mapping xml, I have this field as below: (the rest of the xml is ignored for brevity)



But this field is defined as boolean in my Entity. So how to overcome this? I know that I can use the Hibernate Annotations that has a converter to convert the char to a boolean representation. But that requires the use of annotations and I want to abstain form using annotations in my Entities. Any alternatives?
 
Joe Harry
Ranch Hand
Posts: 10079
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tried the following as a work around in my Entity class:



But even this could not get rid of the error above. Is there any other mistake in what I did?
 
Joe Harry
Ranch Hand
Posts: 10079
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Managed to get rid of this error. I was having the default access as PROPERTY and as soon as I changed it to FIELD access, it started to work.
 
Joe Harry
Ranch Hand
Posts: 10079
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But why is there such a limitation in JPA. Why is there no possibility to convert this automatically to a boolean as I can in Hibernate?
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the Boolean/boolean in property access you have to use is<Property>() & set<Property>(), not what you mentioned.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic