I am currently using H2 as the database engine when running unit tests for 
my project. For a number of my tests it has started failing when the tests 
are run as part of my deployment packaging step (Maven), however the same 
tests will pass when run in Eclipse as a JUnit Test.

Stack trace from the failed mvn command is:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running 
ca.joyes.sportssjef.service.scheduled.SendApprovalRequestNotificationServiceTest
16:02:08.275 [main] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - Syntax error 
in SQL statement "select approvalre0_.uuid as uuid1_18_0_, 
approvalre0_.active as active2_18_0_, approvalre0_.createdBy as 
createdb3_18_0_, approvalre0_.createdDate as createdd4_18_0_, 
approvalre0_.modifiedDate as modified5_18_0_, approvalre0_.updatedBy as 
updatedb6_18_0_, approvalre0_.approvalformquestion_uuid as approval8_18_0_, 
approvalre0_.approvalrequest_uuid as approval9_18_0_, approvalre0_.[*]value 
as value7_18_0_ from approvalrequestresponse approvalre0_ where 
approvalre0_.uuid=?"; expected "identifier"; SQL statement:
select approvalre0_.uuid as uuid1_18_0_, approvalre0_.active as 
active2_18_0_, approvalre0_.createdBy as createdb3_18_0_, 
approvalre0_.createdDate as createdd4_18_0_, approvalre0_.modifiedDate as 
modified5_18_0_, approvalre0_.updatedBy as updatedb6_18_0_, 
approvalre0_.approvalformquestion_uuid as approval8_18_0_, 
approvalre0_.approvalrequest_uuid as approval9_18_0_, approvalre0_.value as 
value7_18_0_ from approvalrequestresponse approvalre0_ where 
approvalre0_.uuid=? [42001-214]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 
13.643 s <<< FAILURE! - in 
ca.joyes.sportssjef.service.scheduled.SendApprovalRequestNotificationServiceTest
[ERROR] 
ca.joyes.sportssjef.service.scheduled.SendApprovalRequestNotificationServiceTest
 
 Time elapsed: 13.642 s  <<< ERROR!
javax.persistence.PersistenceException: 
org.hibernate.exception.SQLGrammarException: could not prepare statement
at 
ca.joyes.sportssjef.service.scheduled.SendApprovalRequestNotificationServiceTest.createApprovalRequest(SendApprovalRequestNotificationServiceTest.java:232)
at 
ca.joyes.sportssjef.service.scheduled.SendApprovalRequestNotificationServiceTest.setup(SendApprovalRequestNotificationServiceTest.java:165)
Caused by: org.hibernate.exception.SQLGrammarException: could not prepare 
statement
at 
ca.joyes.sportssjef.service.scheduled.SendApprovalRequestNotificationServiceTest.createApprovalRequest(SendApprovalRequestNotificationServiceTest.java:232)
at 
ca.joyes.sportssjef.service.scheduled.SendApprovalRequestNotificationServiceTest.setup(SendApprovalRequestNotificationServiceTest.java:165)
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: 
Syntax error in SQL statement "select approvalre0_.uuid as uuid1_18_0_, 
approvalre0_.active as active2_18_0_, approvalre0_.createdBy as 
createdb3_18_0_, approvalre0_.createdDate as createdd4_18_0_, 
approvalre0_.modifiedDate as modified5_18_0_, approvalre0_.updatedBy as 
updatedb6_18_0_, approvalre0_.approvalformquestion_uuid as approval8_18_0_, 
approvalre0_.approvalrequest_uuid as approval9_18_0_, approvalre0_.[*]value 
as value7_18_0_ from approvalrequestresponse approvalre0_ where 
approvalre0_.uuid=?"; expected "identifier"; SQL statement:
select approvalre0_.uuid as uuid1_18_0_, approvalre0_.active as 
active2_18_0_, approvalre0_.createdBy as createdb3_18_0_, 
approvalre0_.createdDate as createdd4_18_0_, approvalre0_.modifiedDate as 
modified5_18_0_, approvalre0_.updatedBy as updatedb6_18_0_, 
approvalre0_.approvalformquestion_uuid as approval8_18_0_, 
approvalre0_.approvalrequest_uuid as approval9_18_0_, approvalre0_.value as 
value7_18_0_ from approvalrequestresponse approvalre0_ where 
approvalre0_.uuid=? [42001-214]
at 
ca.joyes.sportssjef.service.scheduled.SendApprovalRequestNotificationServiceTest.createApprovalRequest(SendApprovalRequestNotificationServiceTest.java:232)
at 
ca.joyes.sportssjef.service.scheduled.SendApprovalRequestNotificationServiceTest.setup(SendApprovalRequestNotificationServiceTest.java:165)


As best as I can tell, the approvalre0_.[*]value column name is only used 
when running from a Maven command, and not seen when running in JUnit. It 
appears that all tests that fail are failing with the [*] identifier in the 
commands issued to the database.

For reference, the persistence configuration I am using is:

<persistence-unit name="sportssjef_test">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="hibernate.archive.autodetection" value="class" />
<!-- H2 -->
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" 
/>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url" 
value="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.jdbc.time_zone" value="UTC"/>
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.flushMode" value="FLUSH_AUTO" />
<property name="org.hibernate.envers.audit_table_suffix" value="_audit" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
</properties>
</persistence-unit>

I have tried to use the hibernate configuration option to globally quote 
identifiers, but that did not correct this problem.

Thank you in advance,
Nathan.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/893629ff-b89b-478c-8682-5c05344fc3e2n%40googlegroups.com.

Reply via email to