Hallo,
ich möchte ein
insert in eine Tabelle machen ohne dafür die ID geben zu müssen, da diese von der Datenbank
automatisch kreiert wird.
Bei der mapping File (
yxz.hbm.xml) muss ich aber die ID definieren denn ich möchte das es gelesen (select) und upgedated wird....
habe mit
<generator class="native"/> versucht, aber da meldet der folgenden Fehler:
Quote:
19:00:49,546 DEBUG SQL:324 - select hibernate_sequence.nextval from dual
19:00:49,609 WARN JDBCExceptionReporter:71 - SQL Error: 2289, SQLState: 42000
19:00:49,609 ERROR JDBCExceptionReporter:72 - ORA-02289: sequence does not exist
19:00:49,625 DEBUG SQLErrorCodeSQLExceptionTranslator:255 - Unable to translate SQLException with errorCode '2289', will now try the fallback translator
19:00:49,625 DEBUG SessionFactoryUtils:785 - Closing Hibernate Session
19:00:49,656 ERROR SeExamplDAOHbnt:100 - attach failed
org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: could not get next sequence value; bad SQL grammar [select hibernate_sequence.nextval from dual]; nested exception is java.sql.SQLException: ORA-02289: sequence does not exist
java.sql.SQLException: ORA-02289: sequence does not exist
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:810)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:850)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1134)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3339)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3384)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:75)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:85)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:463)
at org.springframework.orm.hibernate3.HibernateTemplate$18.doInHibernate(HibernateTemplate.java:693)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:690)
at com.yxz.SeExamplDAOHbnt.attachDirty(SeExamplDAOHbnt.java:97)
at com.yxz.logic.AssManager.insertAssignment(AssManager.java:48)
die map Datei:
Code:
<class name="xx.yy.SeExampl" table="SEEXAMPL" schema="SESM">
<id name="seId" type="long">
<column name="SE_ID" length="13"/>
<generator class="native" />
</id>
.
.
.
Gibt es denn ein Generator, womit man beim select + update die ID bekommt aber beim Insert weggelassen werden kann?
Danke!