Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink does not see created tables in H2 DB
EclipseLink does not see created tables in H2 DB [message #1802734] Thu, 14 February 2019 18:58 Go to next message
Adam Bialas is currently offline Adam BialasFriend
Messages: 14
Registered: July 2016
Junior Member
For test run of the application I am using H2 database 1.4.197. The app is deployed on TomEE 7.1.0 which uses EclipseLink 2.6.4.

I see in logs that during the startup EclipseLink creates tables, sequences etc. Even initialize sequence with value 0:

Quote:
[EL Fine]: 2019-02-14 19:43:59.251--ServerSession(768886654)--Connection(692135986)--Thread(Thread[http-nio-8080-exec-6,5,main])--CREATE TABLE MEMBERACCOUNT (ID BIGINT NOT NULL, FIRSTNAME VARCHAR, LASTNAME VARCHAR, ADDRESS_ID BIGINT, PRIMARY KEY (ID))
[EL Fine]: 2019-02-14 19:43:59.255--ServerSession(768886654)--Connection(116649009)--Thread(Thread[http-nio-8080-exec-6,5,main])--CREATE TABLE ADDRESS (ID BIGINT NOT NULL, CITY VARCHAR, HOUSENO VARCHAR, STREET VARCHAR, PRIMARY KEY (ID))


I also was able to connect via H2 console (I started WebServer manually inside the application) and see there tables / sequences.

When I do a simple select via JPQL then all works fine:
Collection<User> getUsers() {
    Query query = entityManager.createQuery("select u from User u");
    return query.getResultList();
}


However, when I try to insert a new row with persist method:
@Transactional
void saveUser(User user) {
    entityManager.persist(user);
}


then I get the exception that tables do not exist:

Quote:
[EL Warning]: 2019-02-14 19:44:06.529--UnitOfWork(1042838745)--Thread(Thread[http-nio-8080-exec-2,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.h2.jdbc.JdbcSQLException: Tabela "MEMBERACCOUNT" nie istnieje
Table "MEMBERACCOUNT" not found; SQL statement:
INSERT INTO MEMBERACCOUNT (ID, FIRSTNAME, LASTNAME, ADDRESS_ID) VALUES (?, ?, ?, ?) [42102-197]
Error Code: 42102
Call: INSERT INTO MEMBERACCOUNT (ID, FIRSTNAME, LASTNAME, ADDRESS_ID) VALUES (?, ?, ?, ?)
bind => [1, ggg, aaa, null]
Query: InsertObjectQuery(pl.sdacademy.user.MemberAccount@15d6c1e)
14-Feb-2019 19:44:06.530 WARNING [http-nio-8080-exec-2] org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion Unexpected exception from beforeCompletion; transaction will roll back
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.h2.jdbc.JdbcSQLException: Tabela "MEMBERACCOUNT" nie istnieje
Table "MEMBERACCOUNT" not found; SQL statement:
INSERT INTO MEMBERACCOUNT (ID, FIRSTNAME, LASTNAME, ADDRESS_ID) VALUES (?, ?, ?, ?) [42102-197]
Error Code: 42102
Call: INSERT INTO MEMBERACCOUNT (ID, FIRSTNAME, LASTNAME, ADDRESS_ID) VALUES (?, ?, ?, ?)
bind => [1, ggg, aaa, null]
Query: InsertObjectQuery(pl.sdacademy.user.MemberAccount@15d6c1e)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl$1.handleException(EntityManagerSetupImpl.java:745)
at org.eclipse.persistence.transaction.AbstractSynchronizationListener.handleException(AbstractSynchronizationListener.java:275)
at org.eclipse.persistence.transaction.AbstractSynchronizationListener.beforeCompletion(AbstractSynchronizationListener.java:170)
at org.eclipse.persistence.transaction.JTASynchronizationListener.beforeCompletion(JTASynchronizationListener.java:68)
at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:527)
Re: EclipseLink does not see created tables in H2 DB [message #1803437 is a reply to message #1802734] Thu, 28 February 2019 16:53 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
How have you setup your connection pools? Could the read be using a different connection pool from the write operation?
Previous Topic:CommitManager.sort not working if primary key is a byte array
Next Topic:ExpressionBuilder left outer join with on clause
Goto Forum:
  


Current Time: Tue Mar 19 11:00:45 GMT 2024

Powered by FUDForum. Page generated in 0.01894 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top