Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ERROR [AbstractFlushingEventListener] Could not synchronize database state with session  RSS feed

priyaaa sharma
Posts: 1
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I am learning EJB3.0 and doing hands-on also.I got stuck into some issue related to @embeddable non-entity object.I am using MySQL phpMyAdmin and Jboss5.0 application server.

I am facing issues in embeddind a non-entity object named "creditInfo" into a java persistent entity object named "CustomerTable". The entity object CustomerTable is using two secondarytables
"address_table" and "credit_table" . The code was working file untill i add the embedded non-entity "CreditInfo" object.

Code for CustomeTable [Entity Object]:
package bussEntity;

import javax.persistence.*;

* The persistent class for the customer_table database table.
@SecondaryTable(name="address_table" , pkJoinColumns={@PrimaryKeyJoinColumn(name="address_id")}),
@SecondaryTable(name="credit_table" , pkJoinColumns={@PrimaryKeyJoinColumn(name="cc_id")})})
public class CustomerTable implements {
private static final long serialVersionUID = 1L;

@TableGenerator(name="CUST_REG", table="generate_customer_id" ,pkColumnName="PRIMARY_KEY_COLUMN",pkColumnValue="CUST_ID",valueColumnName="VALUE_COLUMN",allocationSize=10)
private int custId;

private String first_Name;

private String last_Name;

private String pan;

private int ssn;

@Column(name="street" , table="address_table")
private String street;
@Column(name="city" , table="address_table")
private String city;
@Column(name="state" , table="address_table")
private String state;

private CreditInfo creditInfo;

public CustomerTable() {

public int getCustId() {
return this.custId;

public void setCustId(int custId) {
this.custId = custId;

public String getFirst_Name() {
return this.first_Name;

public void setFirst_Name(String first_Name) {
this.first_Name = first_Name;

public String getLast_Name() {
return this.last_Name;

public void setLast_Name(String last_Name) {
this.last_Name = last_Name;

public String getPan() {
return this.pan;

public void setPan(String pan) {
this.pan = pan;

public int getSsn() {
return this.ssn;

public void setSsn(int ssn) {
this.ssn = ssn;

public String getStreet() {
return street;

public void setStreet(String street) {
this.street = street;

public String getCity() {
return city;

public void setCity(String city) { = city;

public String getState() {
return state;

public void setState(String state) {
this.state = state;

@AttributeOverrides({@AttributeOverride(name="type" , column=@Column(name="type" , table = "credit_table") ),
@AttributeOverride(name="status" , column=@Column(name="status" , table="credit_table")),
@AttributeOverride(name="limit" , column=@Column(name="limit",table="credit_table")),
@AttributeOverride(name="bankName" , column=@Column(name="bankName",table="credit_table")),
@AttributeOverride(name="cardNum" , column=@Column(name="cardNum",table="credit_table"))
public CreditInfo getCreditInfo() {
return creditInfo;

public void setCreditInfo(CreditInfo creditInfo) {
this.creditInfo = creditInfo;

Code for CreditInfo [non-entity object]:

package bussEntity;


import javax.persistence.Column;
import javax.persistence.Embeddable;

public class CreditInfo implements Serializable{

private static final long serialVersionUID = 1L;

@Column(name="type" , table = "credit_table")
private String type;
@Column(name="status" , table = "credit_table")
private String status;
@Column(name="limit" , table = "credit_table")
private int limit;
@Column(name="bankName" , table = "credit_table")
private String bankName;
@Column(name="cardNum" , table = "credit_table")
private String cardNum;

public CreditInfo(){


public CreditInfo(String type,String status,int limit,String bankName,String cardNum){

public String getType() {
return type;
public void setType(String type) {
this.type = type;
public String getStatus() {
return status;
public void setStatus(String status) {
this.status = status;
public int getLimit() {
return limit;
public void setLimit(int limit) {
this.limit = limit;
public String getBankName() {
return bankName;
public void setBankName(String bankName) {
this.bankName = bankName;
public String getCardNum() {
return cardNum;
public void setCardNum(String cardNum) {
this.cardNum = cardNum;

Credit_table in DB:

type varchar(10)
status varchar(10)
limit int(8)
bankName varchar(10)
cardNum varchar(10)

The code is compiling correctly but it is throwing exception at the time of persistence of data into the DB. The exception message is as follows:
14:35:16,984 WARN [JDBCExceptionReporter] SQL Error: 1064, SQLState: 42000
14:35:16,984 ERROR [JDBCExceptionReporter] 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 'limit, status, type, cc_id) values ('hdfc', '123', 1234, 'proc', 'visa', 30)' at line 1
14:35:16,984 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: could not insert: [bussEntity.CustomerTable]
at org.hibernate.exception.SQLStateConverter.convert(
at org.hibernate.exception.JDBCExceptionHelper.convert(
at org.hibernate.persister.entity.AbstractEntityPersister.insert(
at org.hibernate.persister.entity.AbstractEntityPersister.insert(
at org.hibernate.action.EntityInsertAction.execute(

Please suggest how to resolve this issue and what am i missing in the code. I am unable to find any help in the book and other sites.

Thank You in Advance !!!

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!