Hi, I am using hibernate 2.1 have created a mapping and so on and have managed to retrieve some data from a table using hibernate succesfully. I am now trying to create a record in the database. In my mapping file for the table I have defined as follows:
Code:
<class name="PtfPortfolio" table="PTF_PORTFOLIO">
<id name="ptfPk" column="PTF_PK">
<generator class="native" />
</id>
<property name="name" column="NAME" type="java.lang.String" />
<property name="description" column="DESCRIPTION"
type="java.lang.String" />
<property name="volume" column="VOLUME" type="java.lang.Long" />
</class>
When I try and create a row hibernate complains because it is trying to use the hilo algorithm to generate the value of PTF_PK. Reading the documentation I thought it would use SEQUENCE as I am using ' Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production'
Code:
[21/04/05 17:23:05:660 BST] 0000004f TableGenerato E TRAS0014I: The following exception was logged java.sql.SQLException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:630)
at oracle.jdbc.driver.T2CPreparedStatement.execute_for_describe(T2CPreparedStatement.java:851)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:896)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:986)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2888)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2929)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteQuery(WSJdbcPreparedStatement.java:667)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:477)
at net.sf.hibernate.id.TableGenerator.generate(TableGenerator.java:94)
at net.sf.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.java:59)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:776)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:749)
So I then tried changing the generator class defined to sequence. After redeploying I couldnt even retrieve any data, it is now giving the following exception trace
Code:
[21/04/05 17:06:50:107 BST] 0000004f SystemErr R %%%% Error Creating SessionFactory %%%%
[21/04/05 17:06:50:107 BST] 0000004f SystemErr R net.sf.hibernate.MappingException: could not instantiate id generator
at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:82)
at net.sf.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:82)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:644)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:690)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)
at com.abnamro.att.server.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:47)
Any help appreciated, this is my first use of hibernate so apologies if Im doing something stupid