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 |
Adam Bialas 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)
|
|
| |
Goto Forum:
Current Time: Thu Oct 03 20:35:56 GMT 2024
Powered by FUDForum. Page generated in 0.04637 seconds
|