Play! 1.2.3 change in database setup?

130 views
Skip to first unread message

somatik

unread,
Aug 24, 2011, 4:09:44 PM8/24/11
to play-framework
Hi,

I followed the tutorial and my play app loads initial data on startup
if no users are available.

@OnApplicationStart
public class Bootstrap extends Job {
public void doJob() {
if(User.count() == 0) {
Logger.info("Loading initial data as the database is
empty");
Fixtures.loadModels("initial-data.yml");
}
}
}

This worked for both prod and dev mode on 1.2.2 but does not work any
more on 1.2.3. I think the database schema setup is not being called
any more. Should I file an issue for this or is this expected?

Stacktrace below

1:54:42,715 INFO ~ Connected to jdbc:h2:mem:play;MODE=MYSQL
21:54:43,939 INFO ~ Application 'xxx' is now started !
21:54:44,128 WARN ~ SQL Error: 42102, SQLState: 42S02
21:54:44,128 ERROR ~ Table "USER" not found; SQL statement:
select count(*) as col_0_0_ from User user0_ limit ? [42102-149]
21:54:44,142 ERROR ~

@67g7ad7fo
Error during job execution (boot.Bootstrap)

Execution exception (In /app/boot/Bootstrap.java around line 12)
PersistenceException occured :
org.hibernate.exception.SQLGrammarException: could not execute query

play.exceptions.JavaExecutionException:
org.hibernate.exception.SQLGrammarException: could not execute query
at play.jobs.Job.call(Job.java:155)
at Invocation.Job(Play!)
Caused by: javax.persistence.PersistenceException:
org.hibernate.exception.SQLGrammarException: could not execute query
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:
1214)
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:
1147)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:307)
at play.db.jpa.JPQL.count(JPQL.java:20)
at models.User.count(User.java)
at boot.Bootstrap.doJob(Bootstrap.java:12)
at play.jobs.Job.doJobWithResult(Job.java:50)
at play.jobs.Job.call(Job.java:146)
... 1 more
Caused by: org.hibernate.exception.SQLGrammarException: could not
execute query
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:
92)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:
66)
at org.hibernate.loader.Loader.doList(Loader.java:2536)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
at
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:
363)
at
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:
196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:274)
... 6 more
Caused by: org.h2.jdbc.JdbcSQLException: Table "USER" not found; SQL
statement:
select count(*) as col_0_0_ from User user0_ limit ? [42102-149]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:
327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.command.Parser.readTableOrView(Parser.java:4563)
at org.h2.command.Parser.readTableFilter(Parser.java:1020)
at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1622)
at org.h2.command.Parser.parseSelectSimple(Parser.java:1729)
at org.h2.command.Parser.parseSelectSub(Parser.java:1616)
at org.h2.command.Parser.parseSelectUnion(Parser.java:1461)
at org.h2.command.Parser.parseSelect(Parser.java:1449)
at org.h2.command.Parser.parsePrepared(Parser.java:401)
at org.h2.command.Parser.parse(Parser.java:275)
at org.h2.command.Parser.parse(Parser.java:247)
at org.h2.command.Parser.prepare(Parser.java:201)
at org.h2.command.Parser.prepareCommand(Parser.java:214)
at org.h2.engine.Session.prepareLocal(Session.java:425)
at org.h2.engine.Session.prepareCommand(Session.java:374)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:
1056)
at
org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:
71)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:
233)
at
org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:
534)
at
org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:
452)
at
org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:
161)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:
1700)
at org.hibernate.loader.Loader.doQuery(Loader.java:801)
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:
274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
... 14 more
Exception in thread "main" play.exceptions.JavaExecutionException:
org.hibernate.exception.SQLGrammarException: could not execute query
at play.jobs.Job.call(Job.java:155)
at Invocation.Job(Play!)
Caused by: javax.persistence.PersistenceException:
org.hibernate.exception.SQLGrammarException: could not execute query
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:
1214)
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:
1147)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:307)
at play.db.jpa.JPQL.count(JPQL.java:20)
at models.User.count(User.java)
at boot.Bootstrap.doJob(Bootstrap.java:12)
at play.jobs.Job.doJobWithResult(Job.java:50)
at play.jobs.Job.call(Job.java:146)
... 1 more
Caused by: org.hibernate.exception.SQLGrammarException: could not
execute query
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:
92)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:
66)
at org.hibernate.loader.Loader.doList(Loader.java:2536)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
at
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:
363)
at
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:
196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:274)
... 6 more
Caused by: org.h2.jdbc.JdbcSQLException: Table "USER" not found; SQL
statement:
select count(*) as col_0_0_ from User user0_ limit ? [42102-149]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:
327)
at org.h2.message.DbException.get(DbException.java:167)

Francis De Brabandere

unread,
Aug 24, 2011, 4:52:45 PM8/24/11
to play-framework
correction: it's broken only on 1.2.3 prod mode (dev mode is ok)

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>

--
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

Ivan Meredith

unread,
Aug 24, 2011, 5:54:04 PM8/24/11
to play-fr...@googlegroups.com
Are you using evolutions for schema, or hibernate?

Francis De Brabandere

unread,
Aug 24, 2011, 5:56:41 PM8/24/11
to play-fr...@googlegroups.com
The default, hibernate I suppose? It's an in-memory db that is reset
on every run.

Francis De Brabandere

unread,
Aug 25, 2011, 6:48:30 AM8/25/11
to play-fr...@googlegroups.com
I'll just create an issue for this one then. Will first try to
reproduce it with a simple app.

Cheers,
Francis

On Wed, Aug 24, 2011 at 11:56 PM, Francis De Brabandere

somatik

unread,
Aug 25, 2011, 5:10:12 PM8/25/11
to play-fr...@googlegroups.com
My bad, was a server id issue. I'll try to do some better research next time :-s
Reply all
Reply to author
Forward
0 new messages