Hi All,
This one's really a Hibernate issue, but I've Googling for a solution
for a while without success and I'm not on any Hibernate lists. I also
know there are people on this list who use AppFuse with Oracle.
My app is based on AppFuse 2.0.1 and I develop it against a Postgres
database at home, but Test and Production deployments are against an
Oracle 10g database.
I have tweaked the AppFuse Core Classes (specifically the User class)
because I needed to add a Company attribute. For various reasons that
would be difficult to work around, I am using a Named Query to select
all users associated with a Company. One of the attributes in the list
of Users returned is the (boolean) "enabled" value. Of course, Oracle,
in its ancient wisdom, implements this as an Integer value and Hibernate
seems to handle that seamlessly in most cases. However, it doesn't seem
to be handling it well at all in my Named Query.
I've created a bean to catch my results and specified that as an
AliasToBeanResultTransformer. This works perfectly on my
Postgres-backed development system. However, it blows up on the
Oracle-backed test system with the following error:
[myapp] TRACE [http-80-Processor23] BigDecimalType.nullSafeGet(172) |
returning '1' as column: enabled
[myapp] ERROR [http-80-Processor23] BasicPropertyAccessor.set(94) |
IllegalArgumentException in class:
au.com.myapp.webapp.action.util.SimpleUser, setter method of property:
enabled
[myapp] ERROR [http-80-Processor23] BasicPropertyAccessor.set(98) |
expected type: java.lang.Boolean, actual value: java.math.BigDecimal
[myapp] ERROR [http-80-Processor23] [default].invoke(253) |
Servlet.service() for servlet default threw exception
org.hibernate.PropertyAccessException: IllegalArgumentException occurred
while calling setter of au.com.myapp.webapp.action.util.SimpleUser.enabled
at
org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
at
org.hibernate.transform.AliasToBeanResultTransformer.transformTuple(AliasToBeanResultTransformer.java:65)
at
org.hibernate.hql.HolderInstantiator.instantiate(HolderInstantiator.java:69)
at
org.hibernate.loader.custom.CustomLoader.getResultList(CustomLoader.java:330)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
My bean's "enabled" attribute currently has two setters, one that takes
a boolean and one that takes a java.lang.Number (superclass to
BigDecimal), but I still get the error. I'm wondering if I added a
specific BigDecimal setter whether maybe that would work, however
java.lang.Number is working fine in some other ResultTransformer beans
I'm using elsewhere (albeit for ID field values, not Booleans).
So, my question is:
Is it possible load a boolean column value from a Named Query result
into a ResultTransformer bean in a Database-independant way that works
with Oracle? If so, how?
I note that Hibernate has other types of ResultTransformers with nice
long descriptive names, but I've not been able to find any documentation
on them that describes to me what they do - maybe a different one would
work?
At the moment, I'm looking at having to refactor this part of the app
and most of the ways I've contemplated will involve quite a bit of work,
especially to implement in a DB-agnostic fashion.
TIA,
Rob Hills
Waikiki, Western Australia
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]