PDA

View Full Version : BlobByteArrayType with hbm2java



jholtzman
Aug 31st, 2004, 07:05 PM
I am trying to use the new BlobByteArrayType in my hibernate mappings, but I haven't had any luck finding any documentation or examples. I've set up the hibernate mapping like so:

<property name="chart" type="blob" class="org.springframework.orm.hibernate.support.BlobByte ArrayType"/>

I'm also using the hbm2java ant task to generate my java classes from the hibernate mappings. However, when I run hbm2java, spring complains that there is "No LobHandler found for configuration". I have configured my local session factory like so:

<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFact oryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="lobHandler"><value>${blob.handler}</value></property>

...

(where blob handler is replaces with org.springframework.jdbc.support.lob.DefaultLobHan dler)

I am assuning that this error is thrown because spring is not running when the hbm2java task is run. I'm puzzled, though, because it shouldn't need to be running when simply generating the java source files.

Does anyone have any idea why BlobByteArrayType would complain about a missing lobHandler when it's not even being asked to do its IOC magic?

Juergen Hoeller
Sep 2nd, 2004, 06:20 AM
It complains because the LobHandler is just available at initialization time: During normal runtime, it needs to fetch it on initialization or it won't be able to work later on. Therefore, it currently follows the fail-fast principle and throws the exception on initialization.

The problem is that hbm2java obviously instantiates all custom types too, although it doesn't do data access with them. In the light of this, I'll probably relax the check in our Hibernate LOB types, throwing the exception on actual data access rather than on initialization.

Juergen

jholtzman
Sep 2nd, 2004, 10:53 AM
Thanks Juergen. This relaxed error checking will be a great benefit for those of us who use hbm2java in our build process. I'm looking forward to the 1.1 release!