While developing a web application using spring and hibernate i am getting the following execption.
java.sql.SQLException: ORA-02289: sequence does not exist
While i am trying to insert the data into a table i am usign sequence to increment the value of request_id.
I am using the following coding for inserting
@Override
public void postRequest(RequestInfo requestInfo)
{
Session session = null;
Transaction trans = null;
SessionFactory sessionFactory = null;
sessionFactory=HibernateConfig.getSessionFactory();
session= sessionFactory.openSession();
trans = session.beginTransaction();
session.save(requestInfo);
trans.commit();
session.close();
}
public class HibernateConfig
{
public static SessionFactory sessionFactory;
public static SessionFactory getSessionFactory()
{
sessionFactory = new Configuration().configure().buildSessionFactory();
return sessionFactory;
}
}
In hibernate mapping i have mentioned like this
<id name="requestId" type="int" column="request_id" >
<generator class="sequence">
<param name="sequence">REQUEST_INFO_SEQ</param>
</generator>
</id>
I tried with native also but i couldn't get the values to be get inserted.
i am using oracle 11g.
Can any one give me solution for this.
The insert operation is working fine after giving the sequence name with the schema name like schemaName.sequenceName in the hbm.xml file. Thank you all for responding the query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With