File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes ERROR [AbstractFlushingEventListener] Could not synchronize database state with session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ERROR [AbstractFlushingEventListener] Could not synchronize database state with session" Watch "ERROR [AbstractFlushingEventListener] Could not synchronize database state with session" New topic
Author

ERROR [AbstractFlushingEventListener] Could not synchronize database state with session

priyaaa sharma
Greenhorn

Joined: Jan 05, 2011
Posts: 1

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 java.io.Serializable;
import javax.persistence.*;



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

@Id
@GeneratedValue(strategy=GenerationType.TABLE,generator="CUST_REG")
@TableGenerator(name="CUST_REG", table="generate_customer_id" ,pkColumnName="PRIMARY_KEY_COLUMN",pkColumnValue="CUST_ID",valueColumnName="VALUE_COLUMN",allocationSize=10)
@Column(name="CUST_ID")
private int custId;

@Column(name="First_Name")
private String first_Name;

@Column(name="Last_Name")
private String last_Name;

@Column(name="PAN")
private String pan;

@Column(name="SSN")
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;

@Embedded
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) {
this.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 java.io.Serializable;

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

@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){
setType(type);
setStatus(status);
setLimit(limit);
setBankName(bankName);
setCardNum(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(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2295)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2688)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)

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 !!!

Regards,
Priya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
 
Similar Threads
Question about the @SecondaryTable annotation
Unable to understand exception
EJB3 Beta Certification - EntityManager BASIC notes. (PART II)
JPA entities -- org.hibernate.TypeMismatchException
JSF 1.2,EJB3, and JBOSS: could not initialize proxy - no Session