my dog learned polymorphism*
The moose likes Object Relational Mapping and the fly likes JPA Mapping Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA Mapping Exception" Watch "JPA Mapping Exception" New topic
Author

JPA Mapping Exception

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9426
    
    2

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?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9426
    
    2

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

Joined: Sep 26, 2006
Posts: 9426
    
    2

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

Joined: Sep 26, 2006
Posts: 9426
    
    2

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

Joined: Mar 24, 2008
Posts: 3838

For the Boolean/boolean in property access you have to use is<Property>() & set<Property>(), not what you mentioned.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA Mapping Exception