Hibernate oneToMany SQLGrammarException - java

I have two classes "Project" and "Report". A Project can contain any number of Reports. When I add the first Report to a Project everything is working fine.
But when I add another Report to a Project, and use the saveOrUpdate method on the Project, I get a SQLGrammarException!
I have already checked the names of the columns.
Project mapping:
#Entity
#Table(name = "TB_PROJECT")
public class Project implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.SEQUENCE)
#Column(name ="PROJECT_ID", unique = true, nullable = false)
private int projectID;
#Column(name = "NAME", unique = false, nullable = false)
private String name;
#Column(name = "CLIENT", unique = false, nullable = false)
private String client;
#OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
#JoinTable(name="PROJECT_REPORTS", joinColumns= {#JoinColumn(name="PROJECT_ID", referencedColumnName="PROJECT_ID")}
, inverseJoinColumns= {#JoinColumn(name="REPORT_ID", referencedColumnName="REPORT_ID")})
private List<Report> reportList = new ArrayList<Report>();
Report mapping:
#Entity
#Table(name = "TB_REPORT", uniqueConstraints = {
#UniqueConstraint(columnNames = "REPORT_ID") })
public class Report implements Serializable{
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.SEQUENCE)
#Column(name ="REPORT_ID", unique = true, nullable = false)
private int reportID;
#Column(name = "NAME", unique = false, nullable = false)
private String name;
#Column(name ="AMOUNT_COMPONENTS")
private int amountComponents;
#Column(name ="AMOUT_ACCEPTED")
private int amountAccepted;
#Column(name = "AMOUNT_REJECTED")
private int amountRejected;
#Column(name = "AMOUNT_DRAFT")
private int amountUnderDevelopment;
#Column(name = "AMOUNT_REVIEW")
private int amountUnderReview;
#Column(name = "TODELETE")
private Boolean toDelete = false;
Hibernate:
#Override
public void updatePersistentProject(Project project) {
try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
session.saveOrUpdate(project);
session.getTransaction().commit();
session.close();
} catch (HibernateException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Console output:
Hibernate: select nextval ('hibernate_sequence')
Hibernate: insert into TB_REPORT (REPORT_ID, AMOUT_ACCEPTED, AMOUNT_COMPONENTS, AMOUNT_REJECTED, AMOUNT_DRAFT, AMOUNT_REVIEW, NAME, TODELETE) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update TB_PROJECT set CLIENT = ?, NAME = ?, TO_DELETE = ? where PROJECT_ID=?
Hibernate: update TB_REPORT set AMOUT_ACCEPTED = ?, AMOUNT_COMPONENTS = ?, AMOUNT_REJECTED = ?, AMOUNT_DRAFT = ?, AMOUNT_REVIEW = ?, NAME = ?, TODELETE = ? where REPORT_ID=?
Hibernate: update TB_REPORT set AMOUT_ACCEPTED = ?, AMOUNT_COMPONENTS = ?, AMOUNT_REJECTED = ?, AMOUNT_DRAFT = ?, AMOUNT_REVIEW = ?, NAME = ?, TODELETE = ? where REPORT_ID=?
Hibernate: delete PROJECT_REPORTS where PROJECT_ID=?
Juli 20, 2019 10:07:40 VORM. org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 0, SQLState: 42601
Juli 20, 2019 10:07:40 VORM. org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: FEHLER: Syntaxfehler bei »PROJECT_REPORTS«
Position: 8
Juli 20, 2019 10:07:40 VORM. org.hibernate.internal.ExceptionMapperStandardImpl mapManagedFlushFailure
ERROR: HHH000346: Error during managed flush [org.hibernate.exception.SQLGrammarException: JDBC exception executing SQL [delete PROJECT_REPORTS where PROJECT_ID=?]]
Juli 20, 2019 10:07:40 VORM. org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [ReportServlet] in context with path [/project] threw exception
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: JDBC exception executing SQL [delete PROJECT_REPORTS where PROJECT_ID=?]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1436)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:487)
at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2786)
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:1932)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:456)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:178)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:39)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:272)
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:104)
at dao.ProjectDAOImpl.updatePersistentProject(ProjectDAOImpl.java:70)
at logic.ReportImpl.createReport(ReportImpl.java:39)
at gui.ReportServlet.createReport(ReportServlet.java:223)
at gui.ReportServlet.doGet(ReportServlet.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at gui.LoginFilter.doFilter(LoginFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: org.hibernate.exception.SQLGrammarException: JDBC exception executing SQL [delete PROJECT_REPORTS where PROJECT_ID=?]
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
at org.hibernate.sql.exec.internal.JdbcMutationExecutorImpl.execute(JdbcMutationExecutorImpl.java:77)
at org.hibernate.sql.exec.internal.JdbcMutationExecutorImpl.execute(JdbcMutationExecutorImpl.java:95)
at org.hibernate.sql.exec.internal.JdbcMutationExecutorImpl.execute(JdbcMutationExecutorImpl.java:125)
at org.hibernate.metamodel.model.domain.internal.collection.JoinTableRemovalExecutor.execute(JoinTableRemovalExecutor.java:123)
at org.hibernate.metamodel.model.domain.spi.AbstractPersistentCollectionDescriptor.remove(AbstractPersistentCollectionDescriptor.java:1245)
at org.hibernate.action.internal.CollectionUpdateAction.execute(CollectionUpdateAction.java:78)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:602)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:474)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:358)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1430)
... 39 more
Caused by: org.postgresql.util.PSQLException: FEHLER: Syntaxfehler bei »PROJECT_REPORTS«
Position: 8
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2468)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2211)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:309)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:446)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:370)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:149)
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:124)
at org.hibernate.sql.exec.internal.JdbcMutationExecutorImpl.execute(JdbcMutationExecutorImpl.java:68)
... 49 more

Related

org.postgresql.util.PSQLException: ERROR: relation "sequence" does not exist

I created a Dynamic Web Project with the JPA facet running on Tomcat 9.0.24. I have a single table, called profile, in my Prostgres 10.10 database and I have a single entity "Profile" that I am trying to persist. I am using Eclipse 4.12.0.
The profile table was created using pgAdmin 4 console and it's sequence exists.
Here is my code...
Maven POM:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.7.4</version>
</dependency>
Profile entity:
package za.co.ezimax.entity;
import java.time.LocalDate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity()
#Table(name = "profile")
public class Profile {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private long id;
#Column(name="first_name", nullable = false, length = 80)
private String firstName;
#Column(name="last_name", nullable = false, length = 80)
private String lastName;
#Column(name="birth_date", columnDefinition = "DATE", nullable = false)
private LocalDate birthDate;
#Column(name="sex", nullable = false)
private int sex;
#Column(name="mobile_mac", nullable = false)
private String mobileMac;
#Column(name="mobile_no", nullable = false, length = 12)
private String mobileNo;
#Column(name="registration_date", columnDefinition = "DATE", nullable = false)
private LocalDate registrationDate;
#Column(name="user_password", nullable = false, length = 80)
private char[] userPassword;
public Profile() {
}
}
Code to persist entity:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("ezimax");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
Profile profile = new Profile();
profile.setFirstName("Hendre");
profile.setLastName("Louw");
profile.setSex(1);
profile.setMobileMac("ff:ff:ff:ff:ff:ff:ff:ff");
profile.setMobileNo("+27832000000");
profile.setRegistrationDate(LocalDate.now());
profile.setUserPassword("password".toCharArray());
em.persist(profile);
em.getTransaction().commit();
em.close();
emf.close();
Here is the exception I am getting:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.4.v20190115-ad5b7c6b2a): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: relation "sequence" does not exist
Position: 8
Error Code: 0
Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
bind => [50, SEQ_GEN]
Query: DataModifyQuery(name="SEQUENCE" sql="UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:342)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1650)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:906)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:970)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:640)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:567)
at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2096)
at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:311)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:275)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:261)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:304)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:284)
at org.eclipse.persistence.queries.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:87)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:914)
at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3349)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1895)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1877)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1842)
at org.eclipse.persistence.sequencing.QuerySequence.update(QuerySequence.java:356)
at org.eclipse.persistence.sequencing.QuerySequence.updateAndSelectSequence(QuerySequence.java:293)
at org.eclipse.persistence.sequencing.StandardSequence.getGeneratedVector(StandardSequence.java:75)
at org.eclipse.persistence.sequencing.DefaultSequence.getGeneratedVector(DefaultSequence.java:168)
at org.eclipse.persistence.sequencing.Sequence.getGeneratedVector(Sequence.java:267)
at org.eclipse.persistence.internal.sequencing.SequencingManager$Preallocation_Transaction_NoAccessor_State.getNextValue(SequencingManager.java:487)
at org.eclipse.persistence.internal.sequencing.SequencingManager.getNextValue(SequencingManager.java:1109)
at org.eclipse.persistence.internal.sequencing.ClientSessionSequencing.getNextValue(ClientSessionSequencing.java:72)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.assignSequenceNumber(ObjectBuilder.java:372)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.assignSequenceNumber(ObjectBuilder.java:331)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.assignSequenceNumber(UnitOfWorkImpl.java:532)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNotRegisteredNewObjectForPersist(UnitOfWorkImpl.java:4388)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.registerNotRegisteredNewObjectForPersist(RepeatableWriteUnitOfWork.java:523)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4333)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:596)
at za.co.ezimax.rest.Servlet.doGet(Servlet.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "sequence" does not exist
Position: 8
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2468)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2211)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:309)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:446)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:370)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:149)
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:124)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:898)
... 55 more
As you mentioned you want to use sequences with JPA.
So you have to use the GenerationType.SEQUENCE and configure the name of the sequence:
#Id
#GeneratedValue(
strategy = GenerationType.SEQUENCE,
generator = "sequence-generator"
)
#SequenceGenerator(
name = "sequence-generator",
sequenceName = "the_sequence_name"
)
private long id;
Replace the_sequence_name with the name of the sequence in PostgreSQL.
In your case GenerationType.AUTO translates to GenerationType.TABLE. The code is expecting that there's a table named SEQUENCE containing the values of the sequences. Since it doesn't exist, EclipseLink can't provide you with generated ids.
Either create the table (and the sequence row in it) or use a different GenerationType.

Hibernate: ERROR: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index

I am new to SQL and Hibernate and I need help with the following:
Entity Product has (OneToMany) Entity Category which has some options (List).
I want when saving a Product this to be saved if not already existing, otherwise to be updated. Also, when saving a product I need to save the Category if the Category does not exist. When deleting/updating a Product the Category should not be deleted/updated.
When I tried to have a #GeneratedValue for Category id, each time I run the app, the Products were updated, but the Categories were re-inserted(with different id, without deleting the previous ones).
I then tried the below code (having the Category name as #Id since I know that the name is unique) but then I get the errors you see.
What do I do wrong? I have searched Google and stackoverflow but I could not find a suitable/plain enough solution.
hibernate.cfg.xml:
…
<property name="dialect">org.hibernate.dialect.DerbyDialect</property>
<!-- Echo the SQL to stdout -->
<property name="show_sql">true</property>
<!-- Set the current session context -->
<property name="current_session_context_class">thread</property>
<!-- Drop and re-create the database schema on startup create-drop-->
<property name="hbm2ddl.auto">update</property>
<!-- dbcp connection pool configuration -->
<property name="hibernate.dbcp.initialSize">5</property>
<property name="hibernate.dbcp.maxTotal">20</property>
<property name="hibernate.dbcp.maxIdle">10</property>
<property name="hibernate.dbcp.minIdle">5</property>
<property name="hibernate.dbcp.maxWaitMillis">-1</property>
<mapping class="main.Category" />
<mapping class="main.Product" />
<mapping class="main.Warehouse" />
...
Product Entity:
#Entity
public class Product implements Serializable {
private static final long serialVersionUID = 1L;
#Id
private int pid;
private String pName;
#OneToMany(cascade=CascadeType.ALL,orphanRemoval = true )
private List<Category> categories;
Category Entity:
#Entity
public class Category implements Serializable {
private static final long serialVersionUID = 1L;
#Id
private Integer catid;
private String cname;
#ElementCollection
private List<String>
public class MainApp {
private static SessionFactory sessionFactory;
public static void main(String[] args) {
#SuppressWarnings("unchecked")
List<String> options1 = new ArrayList();
options1.add("option11");
options1.add("option12");
#SuppressWarnings("unchecked")
List<String> options2 = new ArrayList();
options2.add("option21");
options2.add("option22");
Category cat1 = new Category();
cat1.setCatid(1);
cat1.setCname("cat1");
cat1.setcOptions(options1);
Category cat2 = new Category();
cat2.setCatid(2);
cat2.setCname("cat2");
cat2.setcOptions(options2);
#SuppressWarnings("unchecked")
List<Category> categories1 = new ArrayList<>();
categories1.add(cat1);
categories1.add(cat2);
Product product1 = new Product();
product1.setPid(1);
product1.setpName("prod1");
product1.setCategories(categories1);
#SuppressWarnings("unchecked")
List<Category> categories2 = new ArrayList<>();
categories2.add(cat1);
Product prod2 = new Product();
prod2.setPid(2);
prod2.setpName("prod2");
prod2.setCategories(categories2);
Warehouse w1 = new Warehouse(1, "s1");
Warehouse w2 = new Warehouse(2, "s2");
boolean saveWarehouse = true;
boolean testAdd = true;
boolean testDel = false;
sessionFactory = new Configuration().configure().buildSessionFactory();
try (Session session = sessionFactory.openSession()) {
if (testAdd) {
saveProduct(product1);
saveProduct(prod2);
}
if (testDel) {
session.beginTransaction();
session.delete(prod2);
session.getTransaction().commit();
session.close();
}
if (saveWarehouse) {
session.beginTransaction();
session.saveOrUpdate(w1);
session.saveOrUpdate(w2);
session.getTransaction().commit();
session.close();
}
}
System.out.println("PROCESS COMPLETED");
}
public static void saveProduct(Product p) {
try (Session session = sessionFactory.openSession()) {
session.beginTransaction();
session.saveOrUpdate(p);
session.getTransaction().commit();
session.close();
}
}
}
To save space, Getters & Setters omitted.
The output:
Hibernate: alter table Product_Category drop constraint UK_4ipwbaqj6eduy9ca1yi22afph
Hibernate: alter table Product_Category add constraint UK_4ipwbaqj6eduy9ca1yi22afph unique (categories_cname)
Hibernate: select product_.pid, product_.pName as pName2_2_ from Product product_ where product_.pid=?
Hibernate: select category_.cname from Category category_ where category_.cname=?
Hibernate: select category_.cname from Category category_ where category_.cname=?
Hibernate: delete from Product_Category where Product_pid=?
Hibernate: delete from Category_cOptions where Category_cname=?
Hibernate: delete from Category_cOptions where Category_cname=?
Hibernate: insert into Product_Category (Product_pid, categories_cname) values (?, ?)
Hibernate: insert into Product_Category (Product_pid, categories_cname) values (?, ?)
Hibernate: insert into Category_cOptions (Category_cname, cOptions) values (?, ?)
Hibernate: insert into Category_cOptions (Category_cname, cOptions) values (?, ?)
Hibernate: insert into Category_cOptions (Category_cname, cOptions) values (?, ?)
Hibernate: insert into Category_cOptions (Category_cname, cOptions) values (?, ?)
Hibernate: select product_.pid, product_.pName as pName2_2_ from Product product_ where product_.pid=?
Hibernate: select category_.cname from Category category_ where category_.cname=?
Hibernate: insert into Product (pName, pid) values (?, ?)
Hibernate: insert into Product_Category (Product_pid, categories_cname) values (?, ?)
Mar 16, 2019 4:08:17 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 20000, SQLState: 23505
Mar 16, 2019 4:08:17 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'UK_4IPWBAQJ6EDUY9CA1YI22AFPH' defined on 'PRODUCT_CATEGORY'.
Mar 16, 2019 4:08:17 PM org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl release
INFO: HHH000010: On release of batch it still contained JDBC statements
Mar 16, 2019 4:08:17 PM org.hibernate.internal.ExceptionMapperStandardImpl mapManagedFlushFailure
ERROR: HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1490)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:515)
at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3348)
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2519)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:473)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:178)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:39)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:271)
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:104)
at main.MainApp.saveProduct(MainApp.java:96)
at main.MainApp.main(MainApp.java:72)
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:59)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178)
at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1340)
at org.hibernate.action.internal.CollectionRecreateAction.execute(CollectionRecreateAction.java:50)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:478)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:356)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1484)
... 10 more
Caused by: org.apache.derby.shared.common.error.DerbySQLIntegrityConstraintViolationException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'UK_4IPWBAQJ6EDUY9CA1YI22AFPH' defined on 'PRODUCT_CATEGORY'.
at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.ClientPreparedStatement.executeUpdate(Unknown Source)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
... 18 more
Caused by: ERROR 23505: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'UK_4IPWBAQJ6EDUY9CA1YI22AFPH' defined on 'PRODUCT_CATEGORY'.
at org.apache.derby.client.am.ClientStatement.completeExecute(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.readExecute(Unknown Source)
at org.apache.derby.client.net.StatementReply.readExecute(Unknown Source)
at org.apache.derby.client.net.NetPreparedStatement.readExecute_(Unknown Source)
at org.apache.derby.client.am.ClientPreparedStatement.readExecute(Unknown Source)
at org.apache.derby.client.am.ClientPreparedStatement.flowExecute(Unknown Source)
at org.apache.derby.client.am.ClientPreparedStatement.executeUpdateX(Unknown Source)
... 20 more
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:764)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:711)
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:289)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
I had this exception on exactly the same data-base vendor.
The culprit was this line:
#Column(nullable = false, unique = true)
private int fieldName = -1;
So that, it enforced the DB attribute to be unique, when the incoming data
did not satisfy this constraint.
In this case, it has to be set to:
unique = false

org.springframework.dao.InvalidDataAccessResourceUsageException while fetching data from multiple tables

I am getting org.springframework.dao.InvalidDataAccessResourceUsageException exception while fetching data from multiple tables in getMenusByRole. My query is correct and giving expected result on database.
Following is code snippet-
UserDaoImpl.java
package com.msoft.crm.daos;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.stereotype.Repository;
import org.w3c.dom.ls.LSInput;
import com.msoft.crm.entities.Users;
#Repository("UserDao")
public class UserDaoImpl implements UserDao {
#PersistenceContext
private EntityManager entityManager;
public String original,recipientAddress,firstName,userName;
#Override
public List<Users> getAllUsers() {
return new ArrayList<Users>();
}
#Override
public List<Users> validateLogin(String username, String password) {
String hql = "from Users u where u.username = :p_username and u.userPassword = :p_password";
Query q = entityManager.createQuery(hql);
q.setParameter("p_username", username);
q.setParameter("p_password", password);
List<Users> users = q.getResultList();
System.out.println("users : " + users);
return users;
}
#Override
public List<Users> getMenusByRole(long userId) {
String hql = " select ur.role_id ,ur.role_name ,ur.speciality ,ms.section_id ,ms.section_name ,ms.section_position ,"
+ "ms.section_icon ,mi.menu_id ,mi.menu_name ,mi.menu_action ,mi.menu_position ,mi.parent_menu_id "
+ "from MenuPrivileges mp inner join UserRoles ur on mp.role_id = ur.role_id "
+ "inner join MenuItems mi on mp.menu_id = mi.menu_id "
+ "inner join MenuSections ms on mi.section_id = ms.section_id "
+ "where mi.active_ind = '1' and mp.visible_ind = '1' "
+ "and mp.role_id = (select role_id from crm_users where user_id = :user_id) order by ms.section_position asc";
Query q = entityManager.createNativeQuery(hql);
q.setParameter("user_id", userId);
List<Users> l = q.getResultList();
System.out.println("l : " + l);
return l;
}
}
MenuPrivileges.java
package com.msoft.crm.entities;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name="crm_menu_privileges")
public class MenuPrivileges {
#Id
#Column
private int role_id;
#Column
private int menu_id;
#Column
private String visible_ind;
public MenuPrivileges() {
this(0,0,"");
}
public MenuPrivileges(int role_id, int menu_id, String visible_ind) {
this.role_id = role_id;
this.menu_id = menu_id;
this.visible_ind = visible_ind;
}
//getter and setter
}
UserRoles.java
#Entity
#Table(name="crm_user_roles")
public class UserRoles {
#Id
#Column
private int role_id;
#Column
private String role_name;
#Column
private String speciality;
// getters and setters
}
MenuItems.java
#Entity
#Table(name="crm_menu_items")
public class MenuItems {
#Id
#Column
private int section_id;
#Column
private int menu_id;
#Column
private String menu_name;
#Column
private String menu_desc;
#Column
private String menu_action;
#Column
private int menu_position;
#Column
private int parent_menu_id;
#Column
private String active_ind;
// getter and setter
}
MenuSections.javv
#Entity
#Table(name="crm_menu_sections")
public class MenuSections {
#Id
#Column
private int id_pk;
#Column
private int section_id;
#Column
private String section_name;
#Column
private String section_desc;
#Column
private String section_icon;
#Column
private int section_position;
//getter and setter
}
Following is my stacktrace where both queries are working but getting above mentioned exception for getMenuByRole.
Hibernate:
select
users0_.user_id as user_id1_5_,
users0_.aadhar_no as aadhar_n2_5_,
users0_.active_ind as active_i3_5_,
users0_.created_by_user_id as created_4_5_,
users0_.created_date_time as created_5_5_,
users0_.email as email6_5_,
users0_.fname as fname7_5_,
users0_.lname as lname8_5_,
users0_.login_status as login_st9_5_,
users0_.mname as mname10_5_,
users0_.mobile as mobile11_5_,
users0_.photo as photo12_5_,
users0_.role_id as role_id13_5_,
users0_.password as passwor14_5_,
users0_.username as usernam15_5_
from
crm_users users0_
where
users0_.username=?
and users0_.password=?
users : [Users [userId=3, roleId=1, sectionId=0, sectionPosition=0, menuId=0, menuPosition=0, parentMenuId=0, specialityId=0, username=shirin, activeInd=1, loginStatus=1, roleName=null, speciality=null, sectionName=null, sectionIcon=null, menuName=null, menuAction=null, firstName=yogiraj, lastName=kulkarni, mobileNumber=9699999999, middleName=, emailAddress=yogirajk#msoft.co.in, aadhaarNumber=123456987456, profileImg=data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUSEhIVFRUVFRUVFRUVFRAVFhUVFRUWFhUVFRUYHSggGBolHRUVITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OGxAQGy0lHyUtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLf/AABEIALcBEwMBIgACEQEDEQH/xAAcAAABBQEBAQAAAAAAAAAAAAADAAIEBQYBBwj/xAA9EAABAwIEAwUGBAQGAwEAAAABAAIRAyEEBRIxQVFhBiJxgaETMpGxwdEUQlLwI6Lh8QczQ2JykiRTgxX/xAAbAQACAwEBAQAAAAAAAAAAAAADBAECBQAGB//EAC0RAAICAQMCBQIGAwAAAAAAAAABAhEDBBIhMUEFEyJRYTJxI1KBobHwFEKR/9oADAMBAAIRAxEAPwCwxGWADZY/NKUVCF6tmVBunyXm2dM/iFKXQWXBTFiYWqY5qj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mh/7P5X/ZJJeZno4e7/AL+hqLKwpzuh+v8AlqfZDrZ5Qj3/AOV/2SSQ46LH7v8Av6FvOlRku0+ZUnhxD+R2f1HLqqLJswYGkF3I7O+3gkkvd+HenTwS+TB1a3OVk4ZhTudXA8HfZcw+YMAI1ceTvskknnJmesaJWCzOmHSXD4P3+Cp8/wARTbWY5jrOmbO4m428/NJJUyO40ExRSmdo4unPvejvspbcdTH5vR32XElm7UOdiQ3Mqf6vR32SdmNL9Xo77JJKu1FKM52gewPDmukOF7O3HkoTscHQ4m+x33HFJJMJXEawScegWpi2kb3HQoRxDefoUkkPajR8xnPxLefoV38Q3n6FJJRtRyysaa7efoVY0MYyBfhyKSSNh4Yjrnvir9xrMWwi7t54Hmo2KxTdtU+RSSR2Z8Y8gxmjYA4i3GPFFGJbBv6FJJAyRTQbakCFdnP5pJJIW0sf/9k=, fullName=null, userPassword=e7202d28c87440d38bd5bf4ff37c7fcc, createdBy=1, createdDate=2017-06-14 11:16:12.0]]
active ind(service):1
In get menus role user id : 3
Hibernate:
select
ur.role_id ,
ur.role_name ,
ur.speciality ,
ms.section_id ,
ms.section_name ,
ms.section_position ,
ms.section_icon ,
mi.menu_id ,
mi.menu_name ,
mi.menu_action ,
mi.menu_position ,
mi.parent_menu_id
from
MenuPrivileges mp
inner join
UserRoles ur
on mp.role_id = ur.role_id
inner join
MenuItems mi
on mp.menu_id = mi.menu_id
inner join
MenuSections ms
on mi.section_id = ms.section_id
where
mi.active_ind = '1'
and mp.visible_ind = '1'
and mp.role_id = (
select
role_id
from
crm_users
where
user_id = ?
)
order by
ms.section_position asc
2017-11-07 10:27:47.364 WARN 3116 --- [nio-8080-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1146, SQLState: 42S02
2017-11-07 10:27:47.364 ERROR 3116 --- [nio-8080-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper : (conn:143322) Table 'crm_application.MenuPrivileges' doesn't exist
Query is: select ur.role_id ,ur.role_name ,ur.speciality ,ms.section_id ,ms.section_name ,ms.section_position ,ms.section_icon ,mi.menu_id ,mi.menu_name ,mi.menu_action ,mi.menu_position ,mi.parent_menu_id from MenuPrivileges mp inner join UserRoles ur on mp.role_id = ur.role_id inner join MenuItems mi on mp.menu_id = mi.menu_id inner join MenuSections ms on mi.section_id = ms.section_id where mi.active_ind = '1' and mp.visible_ind = '1' and mp.role_id = (select role_id from crm_users where user_id = ?) order by ms.section_position asc, parameters [3]
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:261)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:488)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
at com.msoft.crm.daos.UserDaoImpl$$EnhancerBySpringCGLIB$$337e38b5.getMenusByRole(<generated>)
at com.msoft.crm.services.UserService.validateLogin(UserService.java:44)
at com.msoft.crm.controllers.LoginController.validateLogin(LoginController.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1457)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2117)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1900)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1876)
at org.hibernate.loader.Loader.doQuery(Loader.java:919)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336)
at org.hibernate.loader.Loader.doList(Loader.java:2617)
at org.hibernate.loader.Loader.doList(Loader.java:2600)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2429)
at org.hibernate.loader.Loader.list(Loader.java:2424)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:336)
at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1967)
at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:322)
at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:125)
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606)
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:483)
at com.msoft.crm.daos.UserDaoImpl.getMenusByRole(UserDaoImpl.java:115)
at com.msoft.crm.daos.UserDaoImpl$$FastClassBySpringCGLIB$$da03a52e.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
... 59 more
Caused by: java.sql.SQLSyntaxErrorException: (conn:143322) Table 'crm_application.MenuPrivileges' doesn't exist
Query is: select ur.role_id ,ur.role_name ,ur.speciality ,ms.section_id ,ms.section_name ,ms.section_position ,ms.section_icon ,mi.menu_id ,mi.menu_name ,mi.menu_action ,mi.menu_position ,mi.parent_menu_id from MenuPrivileges mp inner join UserRoles ur on mp.role_id = ur.role_id inner join MenuItems mi on mp.menu_id = mi.menu_id inner join MenuSections ms on mi.section_id = ms.section_id where mi.active_ind = '1' and mp.visible_ind = '1' and mp.role_id = (select role_id from crm_users where user_id = ?) order by ms.section_position asc, parameters [3]
at org.mariadb.jdbc.internal.util.ExceptionMapper.get(ExceptionMapper.java:139)
at org.mariadb.jdbc.internal.util.ExceptionMapper.getException(ExceptionMapper.java:101)
at org.mariadb.jdbc.internal.util.ExceptionMapper.throwAndLogException(ExceptionMapper.java:77)
at org.mariadb.jdbc.MariaDbStatement.executeQueryEpilog(MariaDbStatement.java:226)
at org.mariadb.jdbc.MariaDbClientPreparedStatement.executeInternal(MariaDbClientPreparedStatement.java:233)
at org.mariadb.jdbc.MariaDbClientPreparedStatement.executeQuery(MariaDbClientPreparedStatement.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114)
at com.sun.proxy.$Proxy81.executeQuery(Unknown Source)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70)
... 80 more
Caused by: org.mariadb.jdbc.internal.util.dao.QueryException: Table 'crm_application.MenuPrivileges' doesn't exist
Query is: select ur.role_id ,ur.role_name ,ur.speciality ,ms.section_id ,ms.section_name ,ms.section_position ,ms.section_icon ,mi.menu_id ,mi.menu_name ,mi.menu_action ,mi.menu_position ,mi.parent_menu_id from MenuPrivileges mp inner join UserRoles ur on mp.role_id = ur.role_id inner join MenuItems mi on mp.menu_id = mi.menu_id inner join MenuSections ms on mi.section_id = ms.section_id where mi.active_ind = '1' and mp.visible_ind = '1' and mp.role_id = (select role_id from crm_users where user_id = ?) order by ms.section_position asc, parameters [3]
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readErrorPacket(AbstractQueryProtocol.java:1144)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readPacket(AbstractQueryProtocol.java:1076)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:1031)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQuery(AbstractQueryProtocol.java:203)
at org.mariadb.jdbc.MariaDbClientPreparedStatement.executeInternal(MariaDbClientPreparedStatement.java:224)
... 88 more
2017-11-07 10:27:47.383 ERROR 3116 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
In your getMenusByRole you are using plain SQL and not HSQL. So your table names should be crm_menu_privileges, crm_user_roles and so on.
As you are using the native query, the getResultSet() method will not return an object of User class. The other reason is HQL has not been invoked in this query and it will not be able to map the entities by its own.
In your case, the getResultSet() will return an array of Object as follows:
List<Object[]> l = q.getResultList();
And then you have to extract each element from this returned array.
For example, the Object[0] will return ur.role_id and Object[1] will return ur.role_name and so on as specified in your query.

JPAContainer set relationship through programmatically?

I've two entities and I'm using JPAContainer but I don't know how can use to do a relationship with these 2 entities.
here my code
#Entity
#Table(name="curriculum")
public class Curriculum implements Serializable{
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue
private Long idCurriculum;
#Temporal(TemporalType.DATE)
private Date dataCad;
#Size(min=5, max=50)
#NotNull
#NotEmpty
private String nome;
#NotEmpty
private String sexo;
#Email
#NotEmpty
#NotNull
#Size(max=250)
#Column(unique=true)
private String email;
#NotNull
#NotEmpty
#Size(min=14, max=14)
#Column(unique=true)
private String cpf;
}
#Entity
#Table(name="curriculum2")
public class Curriculum2 implements Serializable{
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue
private Long idC2; //NOT NULL AUTO_INCREMENT,
#NotNull #OneToOne #JoinColumn(name="cpf")
private Curriculum curriculum; //NOT NULL,
#NotNull #Temporal(TemporalType.DATE)
private Date dataNasceu; //NOT NULL,
#NotNull #NotEmpty #Size(min=5, max=50)
private String cidade; //` varchar(50) NOT NULL,
#NotNull #NotEmpty #Size(min=5, max=50)
private String endereco; //` varchar(50) NOT NULL,
#NotNull
private int numero; //` int(11) NOT NULL,
#NotNull #NotEmpty #Size(min=5, max=50)
private String bairro; //` varchar(50) NOT NULL,
}
/** here app UI */
/** datasource */
private final CustomJPAContainer<Curriculum2> datasource = new CustomJPAContainer<Curriculum2>(Curriculum2.class);
private final CustomJPAContainer<Curriculum> dsCurriculum = new CustomJPAContainer<Curriculum>(Curriculum.class);
/** beans */
private final Curriculum2 bean = new Curriculum2();
private final Curriculum curriculum = dsCurriculum.getItem(22L).getEntity();
/** beanfieldgroup validation */
private final BeanFieldGroup<Curriculum2> binder = new BeanFieldGroup<Curriculum2>(Curriculum2.class);
public VerticalLayout buildLayout() {
//mainlayout
mainLayout = new VerticalLayout();
mainLayout.setSpacing(true);
mainLayout.setMargin(true);
//tab
tab = new TabSheet();
tab.setSizeUndefined();
mainLayout.addComponent(tab);
//tab1
vLayout_tab1 = new VerticalLayout();
vLayout_tab1.setMargin(true);
vLayout_tab1.setSpacing(true);
binder.setItemDataSource(bean);
Field<?> field = null;
//data nascimento
field = binder.buildAndBind("Data nascimento", "dataNasceu", PopupDateField.class);
dataNasceu = (PopupDateField) field;
dataNasceu.setDateFormat("dd/MM/yyyy");
vLayout_tab1.addComponent(dataNasceu);
//cidade
field = binder.buildAndBind("Cidade", "cidade", TextUpper.class);
cidade = (TextUpper) field;
cidade.setMaxLength(50);
cidade.setWidth("10cm");
vLayout_tab1.addComponent(cidade);
//endereco
field = binder.buildAndBind("Endereço", "endereco", TextUpper.class);
endereco = (TextUpper) field;
endereco.setMaxLength(50);
endereco.setWidth("10cm");
vLayout_tab1.addComponent(endereco);
//numero
field = binder.buildAndBind("Número", "numero");
numero = (TextField) field;
numero.setWidth("2cm");
numero.selectAll();
numero.addStyleName("numeros");
vLayout_tab1.addComponent(numero);
//bairro
field = binder.buildAndBind("Bairro", "bairro", TextUpper.class);
bairro = (TextUpper) field;
bairro.setWidth("10cm");
vLayout_tab1.addComponent(bairro);
}
/** exception */
15:53:19,600 DEBUG [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - Cannot add or update a child row: a foreign key constraint fails (`ibgdb`.`curriculum2`, CONSTRAINT `FK_curriculuns2_curriculuns` FOREIGN KEY (`cpf`) REFERENCES `curriculum` (`cpf`) ON UPDATE CASCADE) [n/a]
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`ibgdb`.`curriculum2`, CONSTRAINT `FK_curriculuns2_curriculuns` FOREIGN KEY (`cpf`) REFERENCES `curriculum` (`cpf`) ON UPDATE CASCADE)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1041)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2441)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2366)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2350)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at com.sun.proxy.$Proxy30.executeUpdate(Unknown Source)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:96)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:58)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2870)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3381)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:81)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:203)
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:183)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:167)
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:320)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:287)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:193)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:126)
at org.hibernate.ejb.event.EJB3MergeEventListener.saveWithGeneratedId(EJB3MergeEventListener.java:71)
at org.hibernate.event.internal.DefaultMergeEventListener.saveTransientEntity(DefaultMergeEventListener.java:236)
at org.hibernate.event.internal.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:216)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:154)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:76)
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:904)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:888)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:892)
at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:879)
at com.vaadin.addon.jpacontainer.provider.MutableLocalEntityProvider$1.run(MutableLocalEntityProvider.java:141)
at com.vaadin.addon.jpacontainer.provider.MutableLocalEntityProvider.runInTransaction(MutableLocalEntityProvider.java:120)
at com.vaadin.addon.jpacontainer.provider.MutableLocalEntityProvider.addEntity(MutableLocalEntityProvider.java:137)
at com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider.addEntity(CachingMutableLocalEntityProvider.java:164)
at com.vaadin.addon.jpacontainer.JPAContainer.addEntity(JPAContainer.java:1113)
at br.ind.ibg.views.InformacoesView.buttonClick(InformacoesView.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:969)
at com.vaadin.ui.Button.fireClick(Button.java:368)
at com.vaadin.ui.Button$1.click(Button.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
at com.vaadin.server.communication.ServerRpcHandler.handleBurst(ServerRpcHandler.java:207)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:111)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:91)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1382)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
15:53:19,602 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - SQL Error: 1452, SQLState: 23000
15:53:19,602 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - Cannot add or update a child row: a foreign key constraint fails (`ibgdb`.`curriculum2`, CONSTRAINT `FK_curriculuns2_curriculuns` FOREIGN KEY (`cpf`) REFERENCES `curriculum` (`cpf`) ON UPDATE CASCADE)
15:53:19,603 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] - Mark transaction for rollback
15:53:19,603 DEBUG [org.hibernate.engine.transaction.spi.AbstractTransactionImpl] - rolling back
15:53:19,678 DEBUG [org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction] - rolled JDBC Connection
15:53:19,679 DEBUG [org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction] - re-enabling autocommit
How I can persist with JPAContainer these 2 entities ?
This is Hibernate 101.
For proof-of-concept this is easy. You're best bet is to use Spring transaction + hibernate + dao model

JPA Sequence Generator causing ORA-01438: value larger than specified precision allowed for this column for Id column

I am using sequence generator (type long) to generate the sequence. But it throws "ORA-01438: value larger than specified precision allowed for this column". When I delete the Sequence generator annotation from my Entity class it works fine with hard coded user id. Note:all other values for different columns remain same.
[1/3/14 12:04:41:886 IST] 00000033 SystemOut O Hibernate: select FACILITY_MAPPING_SEQ.nextval from dual
[1/3/14 12:04:42:194 IST] 00000033 SystemOut O Hibernate: insert into FACILITY_MAPPING (ACCESS_SYSTEM_LOCATION_NAME, CD_HOME_LOCATION_NAME, CREATED_BY, CREATION_DATE, DEPARTMENT_ID, FACILITY_ID, SYSTEM_TGAD, UPDATE_DATE, UPDATED_BY, FACILITY_MAPPING_PK) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
[1/3/14 12:04:42:115 IST] 00000033 SystemErr R 6348489 [WebContainer : 3] INFO org.apache.bval.jsr303.ConfigurationImpl - ignoreXmlConfiguration == true
[1/3/14 12:04:42:874 IST] 00000033 JDBCException W org.hibernate.util.JDBCExceptionReporter logExceptions SQL Error: 1438, SQLState: 22003
[1/3/14 12:04:42:887 IST] 00000033 JDBCException E org.hibernate.util.JDBCExceptionReporter logExceptions ORA-01438: value larger than specified precision allowed for this column
[1/3/14 12:04:42:887 IST] 00000033 JDBCException W org.hibernate.util.JDBCExceptionReporter logExceptions SQL Error: 1438, SQLState: 22003
[1/3/14 12:04:42:888 IST] 00000033 JDBCException E org.hibernate.util.JDBCExceptionReporter logExceptions ORA-01438: value larger than specified precision allowed for this column
[1/3/14 12:04:42:899 IST] 00000033 RegisteredSyn E WTRN0074E: Exception caught from before_completion synchronization operation: javax.persistence.PersistenceException: org.hibernate.exception.DataException: Could not execute JDBC batch update
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1315)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1321)
at org.hibernate.ejb.AbstractEntityManagerImpl$3.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1235)
at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:122)
at org.hibernate.transaction.synchronization.HibernateSynchronizationImpl.beforeCompletion(HibernateSynchronizationImpl.java:51)
at com.ibm.tx.jta.impl.RegisteredSyncs.coreDistributeBefore(RegisteredSyncs.java:291)
at com.ibm.ws.tx.jta.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:152)
at com.ibm.ws.tx.jta.TransactionImpl.prePrepare(TransactionImpl.java:2338)
at com.ibm.ws.tx.jta.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:557)
at com.ibm.tx.jta.impl.TransactionImpl.processCommit(TransactionImpl.java:1015)
at com.ibm.tx.jta.impl.TransactionImpl.commit(TransactionImpl.java:949)
at com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:438)
at com.ibm.tx.jta.impl.TranManagerSet.commit(TranManagerSet.java:181)
at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:950)
at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:265)
at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:579)
at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:4873)
at com.swissre.bae.shared.services.EJSLocal0SLAddNewFacilityServiceImpl_0f22d836.getUpdateAddNewFacility(EJSLocal0SLAddNewFacilityServiceImpl_0f22d836.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.apache.webbeans.ejb.common.proxy.EjbBeanProxyHandler.invoke(EjbBeanProxyHandler.java:204)
at org.javassist.tmp.java.io.Serializable_$$_javassist_18.getUpdateAddNewFacility(Serializable_$$_javassist_18.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:551)
at com.swissre.bae.server.rpc.BAEController.processCall(BAEController.java:54)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1224)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1032)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3751)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1690)
Caused by: org.hibernate.exception.DataException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:102)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:117)
... 55 more
Caused by: java.sql.BatchUpdateException: ORA-01438: value larger than specified precision allowed for this column
My FacilityMapping class:
#Entity
#Table(name = "FACILITY_MAPPING")
public class FacilityMapping implements Serializable{
private static final long serialVersionUID = 1977735642805030781L;
#Id
#GeneratedValue(strategy =GenerationType.SEQUENCE, generator = "FACILITYMAPPINGPKSEQ")
#SequenceGenerator(name="FACILITYMAPPINGPKSEQ", sequenceName = "FACILITY_MAPPING_SEQ")
#Column(name="FACILITY_MAPPING_PK")
private long faciltiyMappingPk;
#Column(name="SYSTEM_TGAD")
private String systemTGAD;
#Column(name="CD_HOME_LOCATION_NAME")
private String cdHomeLocationName;
#Column(name="ACCESS_SYSTEM_LOCATION_NAME")
private String accSysLocName;
#Column(name="FACILITY_ID")
private long facilityId;
#Column(name="DEPARTMENT_ID")
private long departmentId;
#Column (name="CREATION_DATE")
private Date creationDate;
#Column (name="UPDATE_DATE")
private Date updateDate;
#Column (name="CREATED_BY")
private String createdBy;
#Column (name="UPDATED_BY")
private String updatedBy;
public long getFaciltiyMappingPk() {
return faciltiyMappingPk;
}
public void setFaciltiyMappingPk(long faciltiyMappingPk) {
this.faciltiyMappingPk = faciltiyMappingPk;
}
public String getSystemTGAD() {
return systemTGAD;
}
public void setSystemTGAD(String systemTGAD) {
this.systemTGAD = systemTGAD;
}
public String getCdHomeLocationName() {
return cdHomeLocationName;
}
public void setCdHomeLocationName(String cdHomeLocationName) {
this.cdHomeLocationName = cdHomeLocationName;
}
public String getAccSysLocName() {
return accSysLocName;
}
public void setAccSysLocName(String accSysLocName) {
this.accSysLocName = accSysLocName;
}
public long getFacilityId() {
return facilityId;
}
public void setFacilityId(long facilityId) {
this.facilityId = facilityId;
}
public long getDepartmentId() {
return departmentId;
}
public void setDepartmentId(long departmentId) {
this.departmentId = departmentId;
}
public Date getCreationDate() {
return creationDate;
}
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
}
Please suggest some help
Thanks in Advance
By your exception's stack trace, any of your inserting value is above the precision defined on DB column.
And most probable it will be with value generated by sequence. Just check what next value your sequence generating and increase the size a/c to that.

Categories