[JIRA] (HHH-13943) Exception thrown by JOIN query when package names starts with "in"
by Arul Siva Murugan V (JIRA)
Arul Siva Murugan V ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOWI3YWQ3ODJi... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-13943?atlOrigin=eyJpIjoiOWI3YW... ) HHH-13943 ( https://hibernate.atlassian.net/browse/HHH-13943?atlOrigin=eyJpIjoiOWI3YW... ) Exception thrown by JOIN query when package names starts with "in" ( https://hibernate.atlassian.net/browse/HHH-13943?atlOrigin=eyJpIjoiOWI3YW... )
Change By: Arul Siva Murugan V ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
[ https://github.com/hibernate/hibernate-orm/pull/3338 |https://github.com/hibernate/hibernate-orm/pull/3338]
Facing issue with JOIN Query if the following Entity is preset in a package starting within.
There are many popular domains like "in", "net.in", "co.in" would have package starting "in"
however IN also a keyword causes shift-reduce conflict. To avoid would escape it with a quote of the fully qualified class name of the entity.
Following stack trace
*without quote *
ERROR ErrorCounter - line 1:108: unexpected token: in
ERROR ErrorCounter - line 1:108: unexpected token: in
line 1:108: *unexpected token: in*
at org.hibernate.hql.internal.antlr.HqlBaseParser.fromJoin(HqlBaseParser.java:1618)
at org.hibernate.hql.internal.antlr.HqlBaseParser.fromClause(HqlBaseParser.java:1337)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1045)
at org.hibernate.hql.internal.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:730)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:323)
at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:186)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:279)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907)
at in.musicmaster.db.DAL.ClassScheduleDataDAL.getStudentNextClass(ClassScheduleDataDAL.java:278)
at in.musicmaster.db.MySqlInstance.getStudentNextClass(MySqlInstance.java:132)
at in.musicmaster.backend.APIServer.main(APIServer.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: in near line 1, column 108 \ [select t.firstName, t.lastName, e.numberOfClassesPending from in.musicmaster.db.Models.TutorData as t *join in.musicmaster.db.Models.EnrollmentData* as e on e.tutorId = t.tutorId where t.tutorId = 1]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74)
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:91)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:288)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907)
at in.musicmaster.db.DAL.ClassScheduleDataDAL.getStudentNextClass(ClassScheduleDataDAL.java:278)
at in.musicmaster.db.MySqlInstance.getStudentNextClass(MySqlInstance.java:132)
at in.musicmaster.backend.APIServer.main(APIServer.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
*With quote*
ERROR ErrorCounter - line 1:108: unexpected token: 'in.musicmaster.db.Models.EnrollmentData'
ERROR ErrorCounter - line 1:108: unexpected token: 'in.musicmaster.db.Models.EnrollmentData'
line 1:108: unexpected token:* 'in.musicmaster.db.Models.EnrollmentData'*
at org.hibernate.hql.internal.antlr.HqlBaseParser.fromJoin(HqlBaseParser.java:1618)
at org.hibernate.hql.internal.antlr.HqlBaseParser.fromClause(HqlBaseParser.java:1337)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1045)
at org.hibernate.hql.internal.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:730)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:323)
at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:186)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:279)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907)
at in.musicmaster.db.DAL.ClassScheduleDataDAL.getStudentNextClass(ClassScheduleDataDAL.java:278)
at in.musicmaster.db.MySqlInstance.getStudentNextClass(MySqlInstance.java:132)
at in.musicmaster.backend.APIServer.main(APIServer.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: 'in.musicmaster.db.Models.EnrollmentData' near line 1, column 108 \ [select t.firstName, t.lastName, e.numberOfClassesPending from in.musicmaster.db.Models.TutorData as t join *'in.musicmaster.db.Models.EnrollmentData' *as e on e.tutorId = t.tutorId where t.tutorId = 1]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74)
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:91)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:288)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907)
at in.musicmaster.db.DAL.ClassScheduleDataDAL.getStudentNextClass(ClassScheduleDataDAL.java:278)
at in.musicmaster.db.MySqlInstance.getStudentNextClass(MySqlInstance.java:132)
at in.musicmaster.backend.APIServer.main(APIServer.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
INFO APIServer - Done ...
( https://hibernate.atlassian.net/browse/HHH-13943#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13943#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100124- sha1:185bad4 )
4 years, 6 months
[JIRA] (HHH-13943) Exception thrown by JOIN query when package names starts with "in"
by Arul Siva Murugan V (JIRA)
Arul Siva Murugan V ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMjRiMmM0NzVk... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-13943?atlOrigin=eyJpIjoiMjRiMm... ) HHH-13943 ( https://hibernate.atlassian.net/browse/HHH-13943?atlOrigin=eyJpIjoiMjRiMm... ) Exception thrown by JOIN query when package names starts with "in" ( https://hibernate.atlassian.net/browse/HHH-13943?atlOrigin=eyJpIjoiMjRiMm... )
Issue Type: Bug Affects Versions: 5.4.11, 5.4.12, 5.4.14 Assignee: Arul Siva Murugan V ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) Components: hibernate-core Created: 09/Apr/2020 07:51 AM Environment: Mysql
Labels: hibernate Priority: Critical Reporter: Arul Siva Murugan V ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) Original Estimate: 24h Remaining Estimate: 8h
https://github.com/hibernate/hibernate-orm/pull/3338
Facing issue with JOIN Query if the following Entity is preset in a package starting within.
There are many popular domains like "in", "net.in", "co.in" would have package starting "in"
however IN also a keyword causes shift-reduce conflict. To avoid would escape it with a quote of the fully qualified class name of the entity.
Following stack trace
*without quote *
ERROR ErrorCounter - line 1:108: unexpected token: in
ERROR ErrorCounter - line 1:108: unexpected token: in
line 1:108: *unexpected token: in*
at org.hibernate.hql.internal.antlr.HqlBaseParser.fromJoin(HqlBaseParser.java:1618)
at org.hibernate.hql.internal.antlr.HqlBaseParser.fromClause(HqlBaseParser.java:1337)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1045)
at org.hibernate.hql.internal.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:730)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:323)
at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:186)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:279)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907)
at in.musicmaster.db.DAL.ClassScheduleDataDAL.getStudentNextClass(ClassScheduleDataDAL.java:278)
at in.musicmaster.db.MySqlInstance.getStudentNextClass(MySqlInstance.java:132)
at in.musicmaster.backend.APIServer.main(APIServer.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: in near line 1, column 108 [select t.firstName, t.lastName, e.numberOfClassesPending from in.musicmaster.db.Models.TutorData as t *join in.musicmaster.db.Models.EnrollmentData* as e on e.tutorId = t.tutorId where t.tutorId = 1]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74)
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:91)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:288)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907)
at in.musicmaster.db.DAL.ClassScheduleDataDAL.getStudentNextClass(ClassScheduleDataDAL.java:278)
at in.musicmaster.db.MySqlInstance.getStudentNextClass(MySqlInstance.java:132)
at in.musicmaster.backend.APIServer.main(APIServer.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
*With quote*
ERROR ErrorCounter - line 1:108: unexpected token: 'in.musicmaster.db.Models.EnrollmentData'
ERROR ErrorCounter - line 1:108: unexpected token: 'in.musicmaster.db.Models.EnrollmentData'
line 1:108: unexpected token:* 'in.musicmaster.db.Models.EnrollmentData'*
at org.hibernate.hql.internal.antlr.HqlBaseParser.fromJoin(HqlBaseParser.java:1618)
at org.hibernate.hql.internal.antlr.HqlBaseParser.fromClause(HqlBaseParser.java:1337)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1045)
at org.hibernate.hql.internal.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:730)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:323)
at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:186)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:279)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907)
at in.musicmaster.db.DAL.ClassScheduleDataDAL.getStudentNextClass(ClassScheduleDataDAL.java:278)
at in.musicmaster.db.MySqlInstance.getStudentNextClass(MySqlInstance.java:132)
at in.musicmaster.backend.APIServer.main(APIServer.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: 'in.musicmaster.db.Models.EnrollmentData' near line 1, column 108 [select t.firstName, t.lastName, e.numberOfClassesPending from in.musicmaster.db.Models.TutorData as t join *'in.musicmaster.db.Models.EnrollmentData' *as e on e.tutorId = t.tutorId where t.tutorId = 1]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74)
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:91)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:288)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907)
at in.musicmaster.db.DAL.ClassScheduleDataDAL.getStudentNextClass(ClassScheduleDataDAL.java:278)
at in.musicmaster.db.MySqlInstance.getStudentNextClass(MySqlInstance.java:132)
at in.musicmaster.backend.APIServer.main(APIServer.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
INFO APIServer - Done ...
( https://hibernate.atlassian.net/browse/HHH-13943#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13943#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100124- sha1:185bad4 )
4 years, 6 months
[JIRA] (HHH-13942) >= 5.4.4.Final Causes Version issue with QueryDSL
by Joy Reistad (JIRA)
Joy Reistad ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjQ4MjZlODk4... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-13942?atlOrigin=eyJpIjoiNjQ4Mj... ) HHH-13942 ( https://hibernate.atlassian.net/browse/HHH-13942?atlOrigin=eyJpIjoiNjQ4Mj... ) >= 5.4.4.Final Causes Version issue with QueryDSL ( https://hibernate.atlassian.net/browse/HHH-13942?atlOrigin=eyJpIjoiNjQ4Mj... )
Change By: Joy Reistad ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
My team uses hibernate-core and hibernate-c3p0.
we recently tried to upgrade from version 5.4.1.Final to latest (5.4.14.Final) however this caused our version field to stop updating.
Dug in and found this change starts happening on version 5.4.4.Final.
Hibernate usage:
We use hibernate with queryDSL and javax.persistence
We use javax.Persistence to create an entityManagerFactory with a set of hibernate properties
{code:java}ImmutableMap.Builder<String, String> properties = ImmutableMap.<String, String>builder()
.put("hibernate.connection.url", dbConnectionString)
.put("hibernate.connection.user", dbUser)
.put("hibernate.connection.password", dbPassword)
.put("hibernate.c3p0.min_size", minDbConnections)
.put("hibernate.c3p0.max_size", maxDbConnections)
.put("hibernate.c3p0.timeout", connectionTimeout)
.put("hibernate.c3p0.preferredTestQuery", "/* ping */ SELECT 1")
.put("hibernate.connection.Charset", "utf8")
.put("hibernate.connection.characterEncoding", "utf8")
.put("hibernate.connection.useUnicode", "true");
if (connectionTestOnCheckout) {
properties.put("hibernate.c3p0.testConnectionOnCheckout", "true");
} else {
if (connectionTestOnCheckin) {
properties.put("hibernate.c3p0.testConnectionOnCheckin", "true");
}
properties.put("hibernate.c3p0.idle_test_period", dbIdleCheckInterval);
}
entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnitName, properties.build());{code}
We use the javax.persistence @Entity annotations to represent our object being stored int the db. And we have a version attribute with the @Version annotation
{code:java}import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;
@Entity
@Table(name = "obj", schema = "schema")
public class MyObject {
public MyObject() {
}
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Version
@Column(name = "version")
private Long version;
public Long getId() {
return id;
}
public MyObject setId(Long id) {
this.id = id;
return this;
}
public Long getVersion() {
return version;
}
public MyObject setVersion(Long version) {
this.version = version;
return this;
}
}{code}
We use the LockModeType.WRITE on some of our JPAQueries to force an update to the version object when needed.
however since the hibernate update, entityManager.clear() is clearing the version updates, so the version is not updated ever*
{code:java} MyObj MyObject myObj = new MyObj MyObject ().setVersion(1L);
EntityManager em = entityManagerFactory.createEntityManager();
em.getTransaction().begin();
em.persist(myObj);
em.getTransaction().commit();
em.close();
MyTransaction transaction = new MyTransaction(entityManagerFactory.createEntityManager());
transaction.incrementVersion(myObj.getId);
transaction.commit();{code}
{code:java}import javax.persistence.EntityManager;
import javax.persistence.FlushModeType;
import javax.persistence.LockModeType;
import javax.persistence.RollbackException;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
public class MyTransaction{
private final EntityManager entityManager;
private final JPAQueryFactory queryFactory;
public MyTransaction(EntityManager entityManager) {
this.entityManager = entityManager
this.queryFactory = new JPAQueryFactory(entityManager);
entityManager.setFlushMode(FlushModeType.COMMIT);
entityManager.getTransaction().begin();
}
public void commit() {
//Detaches all JPA managed entities, so that only our explicit updates are persisted. version should still be automatically updated via QueryDSL.
entityManager.clear();
try {
entityManager.getTransaction().commit();
} catch (RollbackException e) {
throw e;
}
}
public void incrementVersion(Long id) {
// QMyObj QMyObject is a Querydsl query type for MyObj MyObject
JPAQuery< MyObj MyObject > query = queryFactory.selectFrom( QMyObj QMyObject. myObj myObject )
.where( QMyObj QMyObject. myObj myObject.id.eq(id));
query.setLockMode(LockModeType.WRITE);
query.fetchOne();
}
public void close() {
try {
if (entityManager.isJoinedToTransaction()) {
entityManager.getTransaction().rollback();
}
} finally {
entityManager.close();
}
}{code}
( https://hibernate.atlassian.net/browse/HHH-13942#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13942#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100124- sha1:c13ca0d )
4 years, 6 months
[JIRA] (HHH-13942) >= 5.4.4.Final Causes Version issue with QueryDSL
by Joy Reistad (JIRA)
Joy Reistad ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiODkxY2IyMGUx... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-13942?atlOrigin=eyJpIjoiODkxY2... ) HHH-13942 ( https://hibernate.atlassian.net/browse/HHH-13942?atlOrigin=eyJpIjoiODkxY2... ) >= 5.4.4.Final Causes Version issue with QueryDSL ( https://hibernate.atlassian.net/browse/HHH-13942?atlOrigin=eyJpIjoiODkxY2... )
Change By: Joy Reistad ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
My team uses hibernate-core and hibernate-c3p0.
we recently tried to upgrade from version 5.4.1.Final to latest (5.4.14.Final) however this caused our version field to stop updating.
Dug in and found this change starts happening on version 5.4.4.Final.
Hibernate usage:
We use hibernate with queryDSL and javax.persistence
We use javax.Persistence to create an entityManagerFactory with a set of hibernate properties
{code:java}
ImmutableMap.Builder<String, String> properties = ImmutableMap.<String, String>builder()
.put("hibernate.connection.url", dbConnectionString)
.put("hibernate.connection.user", dbUser)
.put("hibernate.connection.password", dbPassword)
.put("hibernate.c3p0.min_size", minDbConnections)
.put("hibernate.c3p0.max_size", maxDbConnections)
.put("hibernate.c3p0.timeout", connectionTimeout)
.put("hibernate.c3p0.preferredTestQuery", "/* ping */ SELECT 1")
.put("hibernate.connection.Charset", "utf8")
.put("hibernate.connection.characterEncoding", "utf8")
.put("hibernate.connection.useUnicode", "true");
if (connectionTestOnCheckout) {
properties.put("hibernate.c3p0.testConnectionOnCheckout", "true");
} else {
if (connectionTestOnCheckin) {
properties.put("hibernate.c3p0.testConnectionOnCheckin", "true");
}
properties.put("hibernate.c3p0.idle_test_period", dbIdleCheckInterval);
}
entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnitName, properties.build());
{code}
We use the javax.persistence @Entity annotations to represent our object being stored int the db. And we have a version attribute with the @Version annotation
{code:java}
import java.util.UUID;
import javax.persistence. CascadeType;
import javax.persistence. Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;
@Entity
@Table(name = "obj", schema = "schema")
public class MyObject {
public MyObject() {
}
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Version
@Column(name = "version")
private Long version;
public Long getId() {
return id;
}
public MyObject setId(Long id) {
this.id = id;
return this;
}
public Long getVersion() {
return version;
}
public MyObject setVersion(Long version) {
this.version = version;
return this;
}
}
{code}
* We use the LockModeType.WRITE on some of our JPAQueries to force an update to the version object when needed.
however since the hibernate update, entityManager.clear() is clearing the version updates, so the version is not updated ever*
{code:java}
MyObj myObj = new MyObj().setVersion(1L);
EntityManager em = entityManagerFactory.createEntityManager();
em.getTransaction().begin();
em.persist(myObj);
em.getTransaction().commit();
em.close();
MyTransaction transaction = new MyTransaction(entityManagerFactory.createEntityManager());
transaction.incrementVersion(myObj.getId);
transaction.commit();
{code}
{code:java}
mport import javax.persistence.EntityManager;
import javax.persistence.FlushModeType;
import javax.persistence.LockModeType;
import javax.persistence.RollbackException;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
public class MyTransaction{
private final EntityManager entityManager;
private final JPAQueryFactory queryFactory;
public MyTransaction(EntityManager entityManager) {
this.entityManager = entityManager
this.queryFactory = new JPAQueryFactory(entityManager);
entityManager.setFlushMode(FlushModeType.COMMIT);
entityManager.getTransaction().begin();
}
public void commit() {
//Detaches all JPA managed entities, so that only our explicit updates are persisted. version should still be automatically updated via QueryDSL.
entityManager.clear();
try {
entityManager.getTransaction().commit();
} catch (RollbackException e) {
throw e;
}
}
public void incrementVersion(Long id) {
//QMyObj is a Querydsl query type for MyObj
JPAQuery<MyObj> query = queryFactory.selectFrom(QMyObj.myObj)
.where(QMyObj.myObj.id.eq(id));
query.setLockMode(LockModeType.WRITE);
query.fetchOne();
}
public void close() {
try {
if (entityManager.isJoinedToTransaction()) {
entityManager.getTransaction().rollback();
}
} finally {
entityManager.close();
}
}
{code}
( https://hibernate.atlassian.net/browse/HHH-13942#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13942#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100124- sha1:c13ca0d )
4 years, 6 months