Hi,
With reference to this unanswered post
http://forum.hibernate.org/viewtopic.ph ... ht=xmltype
I have a class where one member is mapped by a UserType to the Oracle XMLType
Code:
<hibernate-mapping package="com.blah.proto.hbm.persistent">
<class name="XMLDocument" table="XML_DOCUMENT" mutable="true" lazy="false" >
<id name="id" type="long" column="ID" length="20">
<generator class="native"/>
</id>
<property name="internalId" type="string" column="INTERNAL_ID" length="37" not-null="true" />
<property name="creationTimeStamp" type="timestamp" column="CREATION_TIMESTAMP" not-null="true"/>
<property name="xmlDoc" type="com.blah.proto.hbm.persistent.usertypes.XMLTypeUserType" column="XML_DOC" not-null="true" />
<property name="docName" type="string" column="DOC_NAME" not-null="true" />
</class>
</hibernate-mapping>
During object creation hibernate makes this insert statement
Code:
insert into XML_DOCUMENT (ID, INTERNAL_ID, XML_DOC, DOC_NAME) values (?, ?, ?, ?)
The insert fails (as does update) with something like "expecting NUMBER got LONG"
If I step through and replace the third
? with
xmltype(?) then I can happily insert and update XMLTypes all day long.
My question is :
Is there existing functionality allowing me to set a value in XMLTypeUserType which tells hibernate a custom value to use in place of
?, by calling
Code:
Insert.addColumn(columnName, customMarker);
instead of
Code:
Insert.addColumn(columnName);
If not I was going to hack hibernate 2.8 to do what I want.
From what I've seen this means making changes to the generateXXXString methods in both net.sf.hibernate.persister.EntityPersister and net.sf.hibernate.persister.NormalizedEntitypersister. Is there anything else I need to be aware of?
I couldn't find anything like this in hibernate 3.0 either (although I may have just not seen it), and it looks like it won't be as easy anyway because the equivalent generateXXXString methods are in the BasicEntityPersister super class, so they have no visibility of the column types.
Is this the kind of configuration that Hibernate should be expected to support, or is it something that is only necessary because of rare vendor specific extensions like XMLType?
Cheers
Simon