I have a strange problem with idbag semantics... i use the mapping document posted here (values with no type specified are simply strings), and with HSQLDB file database i don't have any problem.
Using Oracle9i, the code not works, and the problem is in the element tag of idbag semantics, that in oracle not supports references to custom objects (but with HSQLDB works well!).
Any suggestions?
Hibernate version: 3.1.2
Mapping documents: <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="it.terranova.metadata.support.DB_Group" table="DB_Group"> <id name="id"> <generator class="native"/> </id> <property name="name" not-null="true" /> <property name="description" not-null="true" /> <idbag name="users" lazy="true" table="GROUP_USERS"> <collection-id type="long" column="ID"> <generator class="sequence" /> </collection-id> <key column="USER_ID" /> <element type="it.terranova.metadata.support.DB_User" column="users" /> </idbag> </class> </hibernate-mapping>
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="it.terranova.metadata.support.DB_User" table="DB_User"> <id name="id"> <generator class="native"/> </id> <property name="name" not-null="true" /> <property name="password" not-null="true" /> <property name="userPermissions" type="it.terranova.metadata.support.UserPermissionsTypeCode" /> </class> </hibernate-mapping>
Code between sessionFactory.openSession() and session.close(): session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); session.save(group); session.getTransaction().commit(); session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); List result = session.createQuery("from DB_Group").list(); assertEquals(1, result.size()); Object obj = result.get(0); assertTrue(obj instanceof DB_Group); session.getTransaction().commit();
Full stack trace of any exception that occurs: with HSQLDB no exceptions! With Oracle9i: 15:21:14,702 WARN JDBCExceptionReporter:71 - SQL Error: 1401, SQLState: 23000 15:21:14,722 ERROR JDBCExceptionReporter:72 - ORA-01401: value too large for the column
15:21:14,722 WARN JDBCExceptionReporter:71 - SQL Error: 1401, SQLState: 23000 15:21:14,732 ERROR JDBCExceptionReporter:72 - ORA-01401: value too large for the column
Name and version of the database you are using: Oracle 9i
|