Hello All,
I am new to this Hibernate, had the following problem working with it:
Have a Oracle Table:
Code:
Table Name: CAR and following columns
id integer
make varchar
model varchar
model_year varchar
CarDTO-hbm-xml
<hibernate-mapping>
<class name="com.rnd.dto.CarDTO" table="CAR">
<id name="id" column="ID" type="int">
<generator class="native" />
</id>
<property name="make" type="java.lang.String" column="MAKE"/>
<property name="model" type="java.lang.String" column="MODEL"/>
<property name="modelYear" type="java.lang.String" column="MODEL_YEAR"/>
</class>
</hibernate-mapping>
When saving a car, the following exception is being thrown:
Code:
17:53:17,657 ERROR [JDBCExceptionReporter] ORA-02289: sequence does not exist
17:53:17,657 ERROR [STDERR] org.hibernate.exception.SQLGrammarException: could not get next sequence value
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:96)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:537)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:525)
......................
......................
any idea what's wrong here? How can I get Hibernate generate the ID?
Thanks.