Hibernate version: 2.1.6
Part of Mapping
Code:
<hibernate-mapping package="xxx">
<class
name="Titel"
table="TITLE"
mutable="false">
<id
name="titelNummer"
column="TINR"
type="xxx.type.AssociationIntegerType"
unsaved-value="0">
<generator class="assigned"/>
</id>
....
My Custom-User-TypeCode:
public class AssociationIntegerType implements UserType {
...
Hi there,
i've got only a little question about a UserType as "id" ...
In the JavaDoc of the UserType stands :
Code:
* This interface
* <ul>
* <li>abstracts user code from future changes to the <tt>Type</tt>
* interface,</li>
[....]
* Alternatively, custom types could implement <tt>Type</tt>
* directly or extend one of the abstract classes in
* <tt>net.sf.hibernate.type</tt>. This approach risks future
* incompatible changes to classes or interfaces in that
* package.
That means to me, that it's okay to implement only the'UserType'-Interface.
So, avoiding the mentioned dependencies to "Type" i've only implemented 'UserType'.
But doing so, i'll get an exception:
Code:
net.sf.hibernate.MappingException: Bad identifier type: net.sf.hibernate.type.CustomType
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:660)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:716)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:791)
at de.bsdwest.basweb.persistence.PersistenceFactory.configureHibernate(PersistenceFactory.java:71)
at de.bsdwest.basweb.persistence.PersistenceFactory.<init>(PersistenceFactory.java:30)
at de.bsdwest.basweb.business.service.TestParameterService.setUp(TestParameterService.java:44)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
The exeption occures because a 'Type' is expected. And if i'm looking at the Type-Interface there're a lot of methods my UserType doesn't have.
So my question is, if there's a way to use a 'Custom-User-Type' as '<id type="CustomType" ...' without implementing the 'Type'-Interface or extend a one of the above mentioned abstract classes (due to the dependecies)?
Or is it not possible to do so? Then i will extend an exisiting type ...
thx!
curio