Meaningless Drivel is fun!
The moose likes Java in General and the fly likes Hibernate project Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Hibernate project Exception" Watch "Hibernate project Exception" New topic

Hibernate project Exception

Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238

I am running a example project from intertnet and got exception like

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Hibernate: select hibernate_sequence.nextval from dual
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not get next sequence value
at org.hibernate.exception.SQLStateConverter.convert(
at org.hibernate.exception.JDBCExceptionHelper.convert(
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(
at org.hibernate.impl.SessionImpl.fireSave(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(
at $ Source)
at roseindia.CreateData.main(
Caused by: java.sql.SQLException: ORA-02289: sequence does not exist

at oracle.jdbc.driver.DatabaseError.throwSqlException(
at oracle.jdbc.driver.T4CTTIoer.processError(
at oracle.jdbc.driver.T4CTTIoer.processError(
at oracle.jdbc.driver.T4C8Oall.receive(
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(
... 16 more

createData java looks like

package roseindia;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

public class CreateData {

public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub

SessionFactory sessFact = HibernateUtil.getSessionFactory();
Session sess = sessFact.getCurrentSession();
org.hibernate.Transaction tr = sess.beginTransaction();

Student stu = new Student();
stu.setScourse("B.C.A.");;//Save data
System.out.println("Successfully inserted");

} looks like

package roseindia;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import javax.persistence.Table;;

* @author Rose India
@Table(name = "student")

public class Student implements Serializable{


private int id;
public int getId() {
return id;

public void setId(int id) { = id;

@Column(name="sname", nullable=false,length=40)
private String sname;
public String getSname() {
return sname;

public void setSname(String sname) {
this.sname = sname;

private int sroll;
public int getSroll() {
return sroll;

public void setSroll(int sroll) {
this.sroll = sroll;

private String scourse;
public String getScourse() {
return scourse;

public void setScourse(String scourse) {
this.scourse = scourse;


hibernate.cfg.xml looks like

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
<!-- Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbcracle:thin:@localhost:1521rcl</property>
<property name="connection.username">deliverytest7</property>
<property name="connection.password">dbpassword</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="">none</property>

<mapping class="roseindia.Student"/>


hibernate util class looks like

package roseindia;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateUtil {
//Singleton class
private static final SessionFactory sessionFactory;
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
}catch(Throwable th){
System.err.println("Enitial SessionFactory creation failed"+th);
throw new ExceptionInInitializerError(th);

public static SessionFactory getSessionFactory(){
return sessionFactory;


I was able to insert values outside hibernate through regular java program without any issues.

Any links, resources, ideas, sample code highly appreciated. Thanks in advance

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

Please take the time to choose the correct forum for your posts. This forum is for questions on advanced Java.

For more information, please read this.

This post has been moved to a more appropriate forum.

[Asking smart questions] [About Bear] [Books by Bear]
Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
i found the to close the question. please advise
Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
entity class i changed like

finally this one worked fine

public class Student implements Serializable{


@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="STUDENTID")
@SequenceGenerator(name="STUDENTID", sequenceName = "STUDENTID")
I agree. Here's the link:
subject: Hibernate project Exception
It's not a secret anymore!