Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sequence does not exist

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.

like image 842
Jeeva Avatar asked Dec 29 '25 23:12

Jeeva


1 Answers

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.

like image 53
Jeeva Avatar answered Jan 01 '26 13:01

Jeeva