I write a java maven project for restful webservice using jersey + hibernate and having below error:
javax.servlet.ServletException: org.hibernate.MappingException:
Unknown entity: org.asad.dto.logindetail
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:419)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:
381)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:
221)
hibernate.cfg.xml File:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.postgresql.Drive</property>
<property
name="connection.url">jdbc:postgresql://localhost:5432/logindb</property>
<property name="connection.username">postgres</property>
<property name="connection.password">project</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property
name="dialect">org.hibernate.dialect.PostgreSQLDialect</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="hbm2ddl.auto">update</property>
<propertyname="connection.driver_class">org.postgresql.Driver</property>
<!-- Names the annotated entity class -->
<mapping class="org.asad.dto.logindetail"/>
</session-factory>
</hibernate-configuration>
The table name is "logindetail".
Database Class:
#Entity
#Table (name = "logidetail") public class logindetail {
#Id
int userId;
String name;
String password;
public void setUserId(int i){
this.userId = i;
}
public int getUserId(){
return userId;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setPassword(String pass){
this.password = pass;
}
public String getPassword(){
return password;
}}
Main Class:
package org.asad.login.login.loginservice;
import java.util.ArrayList;
import javax.management.Query;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.asad.dto.logindetail;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configurationimport org.hibernate.classic.Session;
public class LoginService{
SessionFactory sessionFactory = null;
Session session = null;
public String getDatabaseUser(){
logindetail user = null;
String name=null;try{
sessionFactory = new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
session.beginTransaction();
user = (logindetail)session.get(logindetail.class, 2);
name = user.getName();
session.getTransaction().commit();
session.close();
}catch(Exception e){
e.printStackTrace();
}
return name;
}}
now this error is coming java.lang.NullPointerException
anyone can help me to eliminate this error i will b thankful :)
Can you check if you imported correct #Entity annotation.
As #Entity comes under two packages one is org.hibernate.annotations.Entity and other one with javax.persistence.Entity.
Use javax.persistence.Entity to annotate your entity beans. Don't import org.hibernate.annotations.Entity.
Related
I am getting an exception in thread "main" org.hibernate.MappingException: Unknown entity:
Exception in thread "main" org.hibernate.MappingException: Unknown entity: org.koushik.javabrains.dto.UserDetails
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:693)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1485)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:120)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:713)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:701)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:697)
at org.koushik.hibernate.HibernateTest.main(HibernateTest.java:24)
1.
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://localhost:5432/hibernatedb</property>
<property name="connection.username">postgres</property>
<property name="connection.password">16101995</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</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="hbm2ddl.auto">create</property>
<mapping class="org.koushik.javabrains.dto.UserDetails"/>
</session-factory>
2.
package org.koushik.javabrains.dto;
#Entity
public class UserDetails {
#Id
private int userID;
private String userName;
public int getUserID() {
return userID;
}
public void setUserID(int userID) {
this.userID = userID;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
3.
package org.koushik.hibernate;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.koushik.javabrains.dto.UserDetails;
public class HibernateTest {
public static void main(String[] args) {
UserDetails user=new UserDetails();
user.setUserID(1);
user.setUserName("First User");
SessionFactory sessionFactory= new Configuration().configure().buildSessionFactory() ;
Session session= sessionFactory.openSession();
session.beginTransaction();
session.save(user);
session.getTransaction().commit();
session.getTransaction().commit();
session.close();
}
}
i'm sorry if you will consider this post as duplicated, but i couldn't find and answer for my problem. Maybe you can help me) Thanks.
"
INFO: HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#536f2a7e'
***Exception in thread "main" org.hibernate.MappingException: Unknown entity: org.javabrains.UserDetails
at*** org.hibernate.metamodel.internal.MetamodelImpl.entityPersister(MetamodelImpl.java:620)
at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1627)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:104)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192)
at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:38)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177)
at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:32)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:682)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:674)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:669)
at org.javabrains.Main.main(Main.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Main.java
package org.javabrains;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
* Created by roysez on 26.03.2017.
*/
public class Main {
public static void main(final String[] args) throws Exception{
UserDetails user = new UserDetails();
user.setUserId(1);
user.setUserName("Sergiy");
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
session.save(user);
session.getTransaction().commit();
}
}
hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name='connection.driver_class'>com.mysql.jdbc.Driver</property>
<property name='connection.url'>jdbc:mysql://localhost:3306/hibernate</property>
<property name='connection.username'>root</property>
<property name='connection.password'>sergio161098</property>
<!-- JDBC connection pool (use the built-in) -->
<property name='connection.pool_size'>1</property>
<!-- SQL dialect -->
<property name='dialect'>org.hibernate.dialect.MySQLDialect</property>
<!-- Echo all executed SQL to stdout -->
<property name='show_sql'>true</property>
<property name="hbm2ddl.auto">create</property>
<!-- Mapping files -->
<mapping class="org.javabrains.UserDetails"/>
</session-factory>
</hibernate-configuration>
UserDetails.java
package org.javabrains;
import org.hibernate.annotations.Entity;
import javax.persistence.Id;
/**
* Created by roysez on 26.03.2017.
*/
#Entity
public class UserDetails {
#Id
private int userId;
private String userName;
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
I don't know what to do, try all solutions but any of them can't help
If you are intending to use the JPA API, I think you should change line 3 of UserDetails.java:
import org.hibernate.annotations.Entity;
to use JPA annotations:
import javax.persistence.Entity;
Hibernate documentation says org.hibernate.annotations.Entity does not replace javax.persistence.Entity, it just allows to configure additional features.
I think you should put all correct annotations: #Table,#Column,#GeneratedValue etc. in UserDetails.java.
And not forget to have some schema on MySQL server.
And if you are using Hibernate 5 you must use javax.persistence. package for annotations
This question is different from the other questions on the same topic of MappingException: Unknown entity because I have this line in my hibernate config:
<mapping class="bbb.Students" />
My entity class is as follows:
package bbb;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name = "Students")
public class Students implements java.io.Serializable {
private String id;
private String name;
private String number;
#Id
#Column(name = "ID", unique = true, nullable = false)
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
#Column(name = "NAME", nullable = false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#Column(name = "NUMBER", nullable = false)
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
}
I have the database test and the table Students manually created.
The error is:
org.hibernate.MappingException: Unknown entity: bbb.Students
Exception in thread "main" org.hibernate.MappingException: Unknown entity: bbb.Students
at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:776)
at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1533)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:104)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192)
at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:38)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177)
at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:32)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:682)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:674)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:669)
at bbb.App.main(App.java:39)
The Main class is as follows:
package bbb;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
public class App
{
public static void main( String[] args )
{
System.out.println("Hibernate one to one (Annotation)");
Configuration conf = new Configuration();
SessionFactory sf = conf.configure()
.buildSessionFactory(
new StandardServiceRegistryBuilder()
.applySettings(conf.getProperties())
.build());
Session session = sf.openSession();
session.beginTransaction();
Students s = new Students();
s.setId("1");
s.setName("Joe");
s.setNumber("12345");
session.save(s);
session.getTransaction().commit();
System.out.println("Done");
}
}
The full hibernate.config is as follows:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<mapping class="bbb.Students" />
</session-factory>
</hibernate-configuration>
Just imported your Students class in a Hibernate based project. Everything work fine. Before running the application, I created schema "test" manually. Post a class with the main method. Probably something is wrong in it.
Update:
Imported your's main method. The application still works. Can't reproduce an issue.
import bbb.Students;
import org.hibernate.*;
import org.hibernate.cfg.Configuration;
public class Main {
private static final SessionFactory ourSessionFactory;
static {
try {
ourSessionFactory = new Configuration().
configure("hibernate.cfg.xml").
buildSessionFactory();
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static Session getSession() throws HibernateException {
return ourSessionFactory.openSession();
}
public static void main(final String[] args) throws Exception {
final Session session = getSession();
try {
Transaction transaction= session.beginTransaction();
Students student = new Students();
student.setName("Vasua");
student.setNumber("13");
student.setId("1");
session.save(student);
transaction.commit();
} finally {
session.close();
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernte Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">
jdbc:mysql://localhost/stack
</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="connection.username">
root
</property>
<property name="connection.password">
root
</property>
<!-- DB schema will be updated if needed -->
<property name="hbm2ddl.auto">update</property>
<mapping class="bbb.Students"/>
</session-factory>
</hibernate-configuration>
I am a newbie to hibernate framework. I following a tutorial series available on the this link. Here is my model class
package kasun.hibernate.moreAnnotations;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name="UserDetailsMoreAnn")
public class UserDetailsMoreAnnotations {
private int id;
private String name;
private String address;
private Date date;
private String desc;
#Id
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
// public String getDesc() {
// return desc;
// }
// public void setDesc(String desc) {
// this.desc = desc;
// }
}
and this is my Service method
package kasun.hibernate.moreAnnotations;
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class ServiceMethod {
public static void main(String[] args) {
UserDetailsMoreAnnotations objct= new UserDetailsMoreAnnotations();
objct.setName("Kalanka");
objct.setId(7);
objct.setAddress("Kuliyapitiya");
objct.setDate(new Date()); // provide the current date
// objct.setDesc("Younger Brother");
SessionFactory sessionFactory=new Configuration().configure().buildSessionFactory();
Session session= sessionFactory.openSession();
session.beginTransaction();
session.save(objct);
session.getTransaction().commit();
}
}
and this is my hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!-- ~ Hibernate, Relational Persistence for Idiomatic Java ~ ~ License:
GNU Lesser General Public License (LGPL), version 2.1 or later. ~ See the
lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. -->
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<!-- <property name="connection.driver_class">org.hsq/ldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:hsql://localhost/TestDB</property> -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/HibernateTesting1</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<!-- 5) for the kasun.hibernate.moreAnnotations package -->
<mapping class="kasun.hibernate.moreAnnotations.UserDetailsMoreAnnotations" />
</session-factory>
</hibernate-configuration>
Above code runs without errors. The problem I encounter is that when I uncomment the lines
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
in my model class and set a value to desc by uncommenting the line
objct.setDesc("Younger Brother"); in the Service Method
I got a error as Unable to execute command [alter table UserDetailsMoreAnn add column desc varchar(255)] and it says that You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc varchar(255)' at line 1. What I am doing wrong? Can anyone help me to fix this.Thanks in advance
DESC is a reserved keyword in MySQL and cannot be used for field name. Try renaming to Description or something. :)
You can also annotate the field, but must use brackets or escaped quotes:
#Column(name = "[DESC]")
public String getDesc() {
or
#Column(name = "\"DESC\"")
public String getDesc() {
list of reserved words for MySQL 5.7: https://dev.mysql.com/doc/refman/5.7/en/keywords.html
desc is keyword in sql. You should use back tick character(`).
Here i cannot use back tick since stack overflow take it as code sample.
So here i use single quotes. 'desc' varchar(255) instead of desc varchar(255) in database. Using back tick symbol, we can use all reserved keyword in mysql
For back tick, refer https://superuser.com/questions/254076/how-do-i-type-the-tick-and-backtick-characters-on-windows
For entity mapping, refer http://www.mkyong.com/hibernate/how-to-use-database-reserved-keyword-in-hibernate/
I was trying to write my first Hibernate project, while running it I got this exception:
java.lang.ClassCastException: com.SampleProjectDto.UserDetails cannot be cast to com.splwg.base.api.GenericPersistentEntity
Table got created in the DB but values are not inserted in it.
Model class:
package com.SampleProjectDto;
import javax.persistence.Entity;
import javax.persistence.Id;
#Entity
public class UserDetails {
#Id
private int userId;
private String UserName;
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserName() {
return UserName;
}
public void setUserName(String userName) {
UserName = userName;
}
}
hibernate.cfg.xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:#(db_details)</property>
<property name="connection.username">user</property>
<property name="connection.password">password</property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping class ="com.SampleProjectDto.UserDetails"/>
</session-factory>
</hibernate-configuration>
Main Class:
package com.hibernate.test;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistryBuilder;
import com.SampleProjectDto.UserDetails;
public class HibernateTest {
public static void main(String[] args) {
UserDetails user = new UserDetails();
user.setUserId(1);
user.setUserName("Somya");
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
ServiceRegistryBuilder srb = new ServiceRegistryBuilder().applySettings(cfg.getProperties());
SessionFactory sessionFactory = cfg.configure().buildSessionFactory(srb.buildServiceRegistry());
Session session = sessionFactory.openSession();
session.beginTransaction();
session.save(user);
session.getTransaction().commit();
}
}
Error Log:
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.ClassCastException: com.SampleProjectDto.UserDetails cannot be cast to com.splwg.base.api.GenericPersistentEntity
at org.hibernate.event.internal.COBOLCompatibleFlushEntityEventListener.onFlushEntity(COBOLCompatibleFlushEntityEventListener.java:136)
at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:225)
at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1127)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:325)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
at com.hibernate.test.HibernateTest.main(HibernateTest.java:25)
Would appreciate any help on this!
I extended GenericPersistentEntity class, now its working fine.