My setup is hibernate / JPA using hsqldb for doing integration tests. I would like to be able to use a sql script to populate some test data into the database.
Essentially I'm looking for an equivalent of Spring's
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="classpath:test-data-hsql.sql"/>
</jdbc:initialize-database>
Except for this project using Spring is not an option for me. I've read various hsql articles suggesting this is possible using file mode and pointing the path at the script but I haven't been able to get this working.
My persistence.xml
<persistence-unit name="test-pu" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>...</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"></property>
<property name="hibernate.connection.username" value="sa"></property>
<property name="hibernate.connection.password" value=""></property>
<property name="hibernate.connection.url" value="jdbc:hsqldb:file:test-data-hsql"></property>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"></property>
<property name="hibernate.hbm2ddl.auto" value="create"></property>
<property name="hibernate.show_sql" value="true"></property>
</properties>
</persistence-unit>
The test-data-hsql.script does get run but there is always an error.
If I include the DDL statements in the script to create I get
Caused by: org.hsqldb.HsqlException: invalid schema name: INFORMATION_SCHEMA
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.SchemaManager.getUserSchemaHsqlName(Unknown Source)
at org.hsqldb.StatementSchema.getResult(Unknown Source)
at org.hsqldb.StatementSchema.execute(Unknown Source)
at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
If I exclude the DDL statements (hoping I can rely on hbm2ddl.auto = create) then I get
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: INFORMATION_SCHEMA.ONETESTUSER
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.SchemaManager.getUserTable(Unknown Source)
at org.hsqldb.scriptio.ScriptReaderText.processStatement(Unknown Source)
at org.hsqldb.scriptio.ScriptReaderText.readLoggedStatement(Unknown Source)
at org.hsqldb.scriptio.ScriptReaderText.readDDL(Unknown Source)
at org.hsqldb.scriptio.ScriptReaderBase.readAll(Unknown Source)
at org.hsqldb.persist.Log.processScript(Unknown Source)
at org.hsqldb.persist.Log.open(Unknown Source)
at org.hsqldb.persist.Logger.open(Unknown Source)
at org.hsqldb.Database.reopen(Unknown Source)
at org.hsqldb.Database.open(Unknown Source)
at org.hsqldb.DatabaseManager.getDatabase(Unknown Source)
Does anyone have an example with a working script file or a better way to do this? I'm not necessarily tied to hsqldb if there is an alternative that can support this feature.
Update
The Minimal Script I am using to produce the error has no reference to INFORMATION_SCHEMA
drop table AccessToken if exists
create table AccessToken (id integer generated by default as identity (start with 1), createdAt timestamp not null, lastAccessedAt timestamp, token varchar(255) not null, expirationPolicyId varchar(255) not null, userId varchar(255) not null, primary key (id))
insert into ACCESSTOKEN (id, createdAt, lastAccessedAt, token, expirationPolicyId, userId) values (1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'welcome1', 'oneDayPolicy', 'jtrotter');
You need the DDL statements in the script, otherwise the database is empty and you get the second error.
The problem is in the script, is has reference for mySQL specific meta data schema INFORMATION_SCHEMA. Remove reference to objects in that schema so that the create tables can complete.
Related
I am trying to connect to impala and do a simple select query using JdbcTemplate(). I keep getting the following error:
java.sql.SQLException: [Simba][ImpalaJDBCDriver](500164) Error initialized or created transport for authentication: null.
at com.cloudera.impala.hivecommon.api.HiveServer2ClientFactory.createTransport(Unknown Source)
at com.cloudera.impala.hivecommon.api.HiveServer2ClientFactory.createClient(Unknown Source)
at com.cloudera.impala.hivecommon.core.HiveJDBCConnection.connect(Unknown Source)
at com.cloudera.impala.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)
at com.cloudera.impala.jdbc.common.AbstractDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at ProcedureDAOImpl.updateProcedure(ProcedureDAOImpl.java:55)
at MainRunner.procedure1(MainRunner.java:61)
at MainRunner.run(MainRunner.java:33)
at java.util.TimerThread.mainLoop(Unknown Source)
Caused by: com.cloudera.impala.support.exceptions.GeneralException: [Simba][ImpalaJDBCDriver](500164) Error initialized or created transport for authentication: null.
... 11 more
ApplicationContext bean for this connection is defined like this:
<bean id="impalaDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.cloudera.impala.jdbc4.Driver"></property>
<property name="url" value="${jdbc.impala.url}"/>
<property name="username" value="${jdbc.impala.username}"/>
<property name="password" value="${jdbc.impala.password}"/>
</bean>
I tried to connect with DriverManager class and it was successful. But when I try to use dbcp class, it fails. Does anybody have some suggestion on this?
When I got the same error while I was connecting to Impala on DBeaver.
The possible workaround that I found is to keep updating to the latest Impala JDBC driver available.
Note: It works for a while and then I get the same error again. Updating it again solves the problem.
I am using embedded hsql db in my spring boot application and want to
create a schema only if does not exist in the db.
Assuming the schema name is XXX,
I have the below single statement schema-hsql.sql file:
CREATE SCHEMA XXX IF NOT EXISTS
However this is faing with below stack trace:
org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/xxx/schema-hsql.sql]: CREATE SCHEMA XXX IF NOT EXISTS; nested exception is java.sql.SQLSyntaxErrorException: unexpected token: IF
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:494)
at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:231)
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:48)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:157)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runSchemaScripts(DataSourceInitializer.java:81)
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.init(DataSourceInitializer.java:75)
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.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:354)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:305)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
... 65 more
Caused by: java.sql.SQLSyntaxErrorException: unexpected token: IF
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source)
at com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:909)
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:473)
... 77 more
Caused by: org.hsqldb.HsqlException: unexpected token: IF
at org.hsqldb.error.Error.parseError(Unknown Source)
at org.hsqldb.ParserBase.unexpectedToken(Unknown Source)
at org.hsqldb.ParserDDL.getCompiledStatementBody(Unknown Source)
at org.hsqldb.ParserDDL.compileCreateSchema(Unknown Source)
at org.hsqldb.ParserDDL.compileCreate(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
at org.hsqldb.Session.executeDirectStatement(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 81 more
What is the correct syntax for achieving this?
Thanks
use
CREATE SCHEMA IF NOT EXISTS XXX
instead of your sql
CREATE SCHEMA XXX IF NOT EXISTS
and use org.hsqldb::hsqldb v.2.4.0
See:
Hsql - create schema if not exists in spring boot application
You can also specify this in your `hibernate.cfg.xml" as following :
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
Here's full example :
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.h2.Driver</property>
<property name="connection.url">jdbc:h2:file:db/personh2db;DB_CLOSE_DELAY=-1;MVCC=TRUE</property>
<property name="connection.username">sa</property>
<property name="connection.password"/>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.H2Dialect</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping resource="com/example/model/Person.hbm.xml"/>
</session-factory>
The list of possible options for hbm2ddl.autoare,
validate: validate the schema, makes no changes to the database.
update: update the schema.
create: creates the schema, destroying previous data.
create-drop: drop the schema at the end of the session.
EDIT
You can configure hibernate properties in application.properties when you're using Spring boot.
Here's the documentation for application.properties : https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
You can find an example for hbm2ddl.auto configuration here : http://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html#howto-configure-jpa-properties
I am new to Play Framework and I am trying to do a simple example to understand how it works. I have used the template play-spring-data-jpa to start. I would like to use MySQL in a persistent way and that is why I chose it.
I started with h2 to understand how it works and then tried to move to connecting to a MySQL local database.
I followed the steps to use JPA from https://www.playframework.com/documentation/2.1.0/JavaJPA to get a persistence unit.
The code works fine with h2, but when I switch to MySQL, I get an error.
The connection with the database works fine, as I get the message:
[info] play - database [default] connected at jdbc:mysql://localhost/brainUp?useUnicode=yes&characterEncoding=UTF-8&connectionCollation=utf8_general_ci
But right after that message I get the following one:
[error] o.h.t.h.SchemaUpdate - could not get database metadata
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown table 'sequences' in information_schema
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.7.0_51]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[na:1.7.0_51]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_51]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_51]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[mysql-connector-java-5.1.18.jar:na]
at com.mysql.jdbc.Util.getInstance(Util.java:386) ~[mysql-connector-java-5.1.18.jar:na]
[error] o.h.t.h.SchemaUpdate - could not complete schema update
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown table 'sequences' in information_schema
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.7.0_51]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[na:1.7.0_51]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_51]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_51]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[mysql-connector-java-5.1.18.jar:na]
at com.mysql.jdbc.Util.getInstance(Util.java:386) ~[mysql-connector-java-5.1.18.jar:na]
I don't quite understand the message and I have been searching for quite long and have not found anything that makes me understand what is happening.
Thanks in advance
Thank you #Krzysiek for the interest. I revised the persistence.xml again and found the error there. As I think you suspected it was about the defined dialect.
As I previously used h2, so the dialect was defined for that instead of for MySQL.
Here's the new persistence.xml which works fine, in case someone encounters the same problem as me.
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
</persistence>
I also would like to note for new users like me that if you want to create the tables from java code you should set to create-drop, and just to use and edit data stored you might want to switch it to "update" instead, when the database is created and will not suffer structural changes anymore.
I am very new to hibernate so I am practicing by seeing video tutorial. The link I am following is,
https://www.youtube.com/watch?v=FFMOZY4z6bE&list=PL4AFF701184976B25&index=5
It is simple java project in eclipse. Here I use mysql Data base. Here is my Hibernate.cfg.xml file,
com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/hibernatedb
root
root
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MYSQLDialect</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<!-- Names the annotated entity class -->
<mapping class="com.***.dto.UserDetails"/>
I am getting this kind of error ,
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" org.hibernate.HibernateException: Dialect class not found: org.hibernate.dialect.MYSQLDialect
at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:159)
at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:99)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:117)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
at com.aurodisplay.hibernate.HibernateTest.main(HibernateTest.java:17)
Caused by: java.lang.ClassNotFoundException: org.hibernate.dialect.MYSQLDialect
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:156)
Can any one help me in this.
If you are using a property file, then make sure there is no space at the end of the line.
hibernate.dialect=org.hibernate.dialect.MySQLDialect
The answer is in the question. You've found MySQLDialect in your jar files, but your configuration file tries to use MYSQLDialect. Java is case-sensitive.
Try changing to below
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
If you are using
<org.hibernate.dialect.MySQL8Dialect</property>
simply remove 8 from there
<org.hibernate.dialect.MySQLDialect</property>
My team and me are currently working at a project using Hibernate-Validation and JPA.
Problem: we decided to use "drop-and-create-table" during the development-phase. everything worked just fine and as everything was implemented we changed the generation-mode to "none" (with a stable database running).
What it was doing before: We drop the table, create the table from our entities with specific attributes and fill the table with some datasets.
What it is doing now: We work on the existing, previously working, table (already filled with some data); but now some relations seem to be missing.
Now we have encountered a number of Exceptions during runtime and we can't locate them. It seems, that some attribute-relationships were deleted or something, because there are Exceptions (e.g. NullPointerExceptions) thrown, that were not thrown before.
Is there anything else we have to change in the persistence.xml, except the generation-mode?
here's the code for the persistance.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="ticketline" transaction-type="RESOURCE_LOCAL">
<class>at.ticketline.entity.Veranstaltung</class>
<class>at.ticketline.entity.Saal</class>
<class>at.ticketline.entity.Reihe</class>
<class>at.ticketline.entity.Platz</class>
<class>at.ticketline.entity.Person</class>
<class>at.ticketline.entity.Ort</class>
<class>at.ticketline.entity.News</class>
<class>at.ticketline.entity.Kunde</class>
<class>at.ticketline.entity.Kuenstler</class>
<class>at.ticketline.entity.Kategorie</class>
<class>at.ticketline.entity.Bestellung</class>
<class>at.ticketline.entity.BestellPosition</class>
<class>at.ticketline.entity.BaseEntity</class>
<class>at.ticketline.entity.Auffuehrung</class>
<class>at.ticketline.entity.Artikel</class>
<class>at.ticketline.entity.Adresse</class>
<class>at.ticketline.entity.Benutzer</class>
<class>at.ticketline.entity.Ticket</class>
<class>at.ticketline.entity.compositekeys.PlatzPK</class>
<class>at.ticketline.entity.compositekeys.ReihePK</class>
<class>at.ticketline.entity.compositekeys.SaalPK</class>
<class>at.ticketline.entity.compositekeys.AuffuehrungPK</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:hsql://localhost/ticketline" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="eclipselink.ddl-generation" value="none" />
</properties>
</persistence-unit>
</persistence>
Stack-Trace:
!STACK 0
java.lang.NullPointerException
at at.ticketline.kassa.ui.editor.TicketSuchergebnisEditor$11.getText(TicketSuchergebnisEditor.java:253)
at org.eclipse.jface.viewers.ColumnLabelProvider.update(ColumnLabelProvider.java:36)
at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:152)
at org.eclipse.jface.viewers.AbstractTableViewer.doUpdateItem(AbstractTableViewer.java:399)
at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run(StructuredViewer.java:485)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:2167)
at org.eclipse.jface.viewers.AbstractTableViewer.createItem(AbstractTableViewer.java:277)
at org.eclipse.jface.viewers.AbstractTableViewer.internalRefreshAll(AbstractTableViewer.java:757)
at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:649)
at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:636)
at org.eclipse.jface.viewers.AbstractTableViewer$2.run(AbstractTableViewer.java:592)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1443)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1404)
at org.eclipse.jface.viewers.AbstractTableViewer.inputChanged(AbstractTableViewer.java:590)
at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:280)
at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1690)
at at.ticketline.kassa.ui.editor.TicketSuchergebnisEditor.createPartControl(TicketSuchergebnisEditor.java:67)
at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:670)
at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1245)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1198)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1597)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:493)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:479)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:808)
at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:707)
at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:666)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2942)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2850)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2842)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2793)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2789)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2773)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2756)
at at.ticketline.kassa.ui.command.TicketSucheResultsCommandHandler.execute(TicketSucheResultsCommandHandler.java:28)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:178)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:247)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:247)
at at.ticketline.kassa.ui.view.TicketSucheView.openEditor(TicketSucheView.java:246)
at at.ticketline.kassa.ui.view.TicketSucheView$1.widgetSelected(TicketSucheView.java:194)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at at.ticketline.kassa.TicketlineApplication.start(TicketlineApplication.java:21)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
My guess is that your database is missing some data.
When you run your populate in memory, you are populating the shared cache and the database. However you are most likely no building your objects correctly.
Maybe you have transient fields that you set in memory, but when you read from the database, these transient fields are null.
Maybe you have bi-directional relationships and are not setting both sides of the relationships, so are not populating the database correctly.
Maybe you have not mapped some attributes correctly, so the data in the database is not correct.
My guess is that if you disabled the shared cache, you would have the same errors.