Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rollback exception....

 
vijay prasanth
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im trying a simple JPA program to persist an object.

My code:
public int saveExam(BookTO bookto){
//creating the entity manager
System.out.println("11");
EntityManager manager=(EntityManager) Persistence.createEntityManagerFactory("POJOHandsOn").createEntityManager();
//starting the transaction
manager.getTransaction().begin();
System.out.println("12");
/*
* creating an entity object and populating it with the
* data from the transfer object
*/
Book book=new Book();
book.setBookName(bookto.getBookName());
book.setBookType(bookto.getBookType());
book.setEmployeeNo(bookto.getEmployeeNo());
book.setEmployeeType(bookto.getEmployeeType());
book.setDuration(bookto.getDuration());

//persisting the data and committing the transaction
//manager.persist(book);
manager.merge(book);
manager.getTransaction().commit();
bookto.setIssueId(book.getIssueId());
return bookto.getIssueId();
}

Entity:
-------

package bookPersistenceTier;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PostPersist;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
* <h3>Description :</h3>This is the entity class of Book
* @author Java_Team,E&R Mysore, Infosys Technologies Limited
*/
@Entity
@Table(name="handson_book")
public class Book {
/*
* book id
*/
@Id
@SequenceGenerator(name="issue_Id",sequenceName="seq_issues_id",initialValue=1001,allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="issue_Id")
private int issueId;
/*
* book name
*/
private String bookName;
/*
* book Type
*/
private char bookType;
/*
* employee No
*/
private int employeeNo;
/*
* designation of employee
*/
private String employeeType;
/*
* duration of the issue of book
*/
private int duration;

/**
* @return the IssueID
*/
public int getIssueId() {
return issueId;
}
/**
* @param issueId the issueID to set
*/
public void setIssueId(int issueId) {
this.issueId = issueId;
}
/**
* @return the bookName
*/
public String getBookName() {
return bookName;
}
/**
* @param bookName the bookName to set
*/
public void setBookName(String bookName) {
this.bookName = bookName;
}
/**
* @return the bookType
*/
public char getBookType() {
return bookType;
}
/**
* @param bookType the bookType to set
*/
public void setBookType(char bookType) {
this.bookType = bookType;
}
/**
* @return the employee no
*/
public int getEmployeeNo() {
return employeeNo;
}
/**
* @param employeeNo the employee number to set
*/
public void setEmployeeNo(int employeeNo) {
this.employeeNo = employeeNo;
}
/**
* @return the employee type
*/
public String getEmployeeType() {
return employeeType;
}
/**
* @param employeeType the employeeType to set
*/
public void setEmployeeType(String employeeType) {
this.employeeType = employeeType;
}
/**
* @return the duration
*/
public int getDuration() {
return duration;
}
/**
* @param duration the duration to set
*/
public void setDuration(int duration) {
this.duration = duration;
}
@PrePersist
@PostPersist
public void s(){
System.out.println("qqqqq");
}
}

but when i try to run it shows Runtime exception-Rollback Exception , table or view not found

Exception in thread "main" Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-00942: table or view does not exist

Error Code: 942
Call: SELECT ISSUEID, BOOKTYPE, EMPLOYEENO, BOOKNAME, EMPLOYEETYPE, DURATION FROM handson_book WHERE (ISSUEID = ?)
bind => [0]
Query: ReadObjectQuery(bookPersistenceTier.Book)
at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:566)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:452)
at oracle.toplink.essentials.threetier.ServerSession.executeCall(ServerSession.java:473)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:214)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.selectOneRow(DatasourceCallQueryMechanism.java:635)
at oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.selectOneRowFromTable(ExpressionQueryMechanism.java:2453)
at oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.selectOneRow(ExpressionQueryMechanism.java:2428)
at oracle.toplink.essentials.queryframework.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:365)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:724)
at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:692)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:746)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
at oracle.toplink.essentials.internal.sessions.AbstractSession.readObject(AbstractSession.java:2191)
at oracle.toplink.essentials.internal.sessions.MergeManager.registerObjectForMergeCloneIntoWorkingCopy(MergeManager.java:695)
at oracle.toplink.essentials.internal.sessions.MergeManager.mergeChangesOfCloneIntoWorkingCopy(MergeManager.java:411)
at oracle.toplink.essentials.internal.sessions.MergeManager.mergeChanges(MergeManager.java:264)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.mergeCloneWithReferences(UnitOfWorkImpl.java:2723)
at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.mergeCloneWithReferences(RepeatableWriteUnitOfWork.java:219)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.mergeInternal(EntityManagerImpl.java:235)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.merge(EntityManagerImpl.java:128)
at bookBusinessTier1.BookService.saveExam(BookService.java:33)
at bookBusinessTier1.BookManager.issueBook(BookManager.java:35)
at bookBusinessTier1.BookWrapper.issueBook(BookWrapper.java:11)
at bookBusinessTier.BookTester.readBookInfo(BookTester.java:35)
at bookBusinessTier.Starter.main(Starter.java:31)
Caused by: java.sql.SQLException: ORA-00942: table or view does not exist

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:830)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2391)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:726)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:501)
... 28 more

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic