diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java index 6fbc8769d..787cdb9db 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java @@ -51,12 +51,13 @@ public class TemplateFactory { private static final Pattern elementPattern = Pattern.compile( """ - \\{\ - (%?%?)\ - (\\d+)\ - (?:([+-/*])(?:(\\d+)|'(-?\\d+(?:\\.\\d+)?)'))?\ - ([slu%]?%?)\ - \\}"""); + \\{\ + (%?%?)\ + (\\d+)\ + (?:([+-/*])(?:(\\d+)|'(-?\\d+(?:\\.\\d+)?)'))?\ + ([slu%]?%?)\ + \\}\ + """); private final Map cache = Collections.synchronizedMap(new WeakHashMap<>()); diff --git a/querydsl-libraries/querydsl-jpa/pom.xml b/querydsl-libraries/querydsl-jpa/pom.xml index 84aeb1f22..9d5a93ca2 100644 --- a/querydsl-libraries/querydsl-jpa/pom.xml +++ b/querydsl-libraries/querydsl-jpa/pom.xml @@ -35,6 +35,13 @@ + + org.hibernate.orm + hibernate-community-dialects + ${hibernate.version} + provided + true + jakarta.persistence diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java index 9772964c1..f4971930e 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java @@ -518,17 +518,18 @@ protected void visitOperation( throw new IllegalArgumentException( String.format( """ - SQL Expressions like %s are not supported in JPQL - the query language for JPA.\ - SQLExpressions.* can only be used in JPQL queries when these functions\ - are registered as custom function in your ORM.%n To fix this issue, you\ - have three options:%n 1) If you do want to use advanced, dialect\ - specific, SQL functions within JPQL, make sure to make these functions\ - available to your ORM through custom functions and register these with\ - your JPATemplates instance.%n 2) Use JPASQLQuery instead. This allows\ - you to generate a pure SQL query based on your JPA metamodel.%n 3)\ - Consider using the Blaze-Persistence QueryDSL integration.\ - Blaze-Persistence is an extension on top of JPA that makes various SQL\ - specific functions like window functions available to JPQL.""", + SQL Expressions like %s are not supported in JPQL - the query language for JPA.\ + SQLExpressions.* can only be used in JPQL queries when these functions\ + are registered as custom function in your ORM.%n To fix this issue, you\ + have three options:%n 1) If you do want to use advanced, dialect\ + specific, SQL functions within JPQL, make sure to make these functions\ + available to your ORM through custom functions and register these with\ + your JPATemplates instance.%n 2) Use JPASQLQuery instead. This allows\ + you to generate a pure SQL query based on your JPA metamodel.%n 3)\ + Consider using the Blaze-Persistence QueryDSL integration.\ + Blaze-Persistence is an extension on top of JPA that makes various SQL\ + specific functions like window functions available to JPQL.\ + """, operator.name()), e); } else { diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java index e7fa43851..e491c8ce4 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java @@ -107,8 +107,10 @@ public long fetchCount() { try { if (getMetadata().getGroupBy().size() > 1 || getMetadata().getHaving() != null) { logger.warning( - "Fetchable#fetchCount() was computed in memory! See the Javadoc for" - + " AbstractJPAQuery#fetchCount for more details."); + """ + Fetchable#fetchCount() was computed in memory! See the Javadoc for\ + AbstractJPAQuery#fetchCount for more details.\ + """); var query = createQuery(null, false); return query.getResultList().size(); } @@ -286,8 +288,10 @@ public QueryResults fetchResults() { var modifiers = getMetadata().getModifiers(); if (getMetadata().getGroupBy().size() > 1 || getMetadata().getHaving() != null) { logger.warning( - "Fetchable#fetchResults() was computed in memory! See the Javadoc for" - + " AbstractJPAQuery#fetchResults for more details."); + """ + Fetchable#fetchResults() was computed in memory! See the Javadoc for\ + AbstractJPAQuery#fetchResults for more details.\ + """); var query = createQuery(null, false); @SuppressWarnings("unchecked") List resultList = query.getResultList(); diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/QDerbyDialect.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/QDerbyDialect.java index 7e9c4572d..8f8d62f9b 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/QDerbyDialect.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/QDerbyDialect.java @@ -16,7 +16,7 @@ import com.querydsl.core.types.Ops; import com.querydsl.sql.DerbyTemplates; import org.hibernate.boot.model.FunctionContributions; -import org.hibernate.dialect.DerbyDialect; +import org.hibernate.community.dialect.DerbyDialect; /** {@code QDerbyDialect} extends {@code DerbyDialect} with additional functions */ public class QDerbyDialect extends DerbyDialect { diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java index 6f2269642..5d580ef64 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java @@ -283,6 +283,7 @@ public void aggregates_uniqueResult_min() { } @Test + @NoEclipseLink public void alias() { assertThat(query().from(cat).select(cat.id.as(cat.id)).fetch()).hasSize(6); } diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateBase.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateBase.java index 4b2871944..bd2156333 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateBase.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateBase.java @@ -81,7 +81,7 @@ public void setSession(Session session) { @Override protected void save(Object entity) { - session.save(entity); + session.persist(entity); } @Test diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateSQLBase.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateSQLBase.java index e75c17421..acae72022 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateSQLBase.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateSQLBase.java @@ -56,12 +56,12 @@ public void setSession(Session session) { @Before public void setUp() { if (query().from(cat).fetchCount() == 0) { - session.save(new Cat("Beck", 1, Color.BLACK)); - session.save(new Cat("Kate", 2, Color.BLACK)); - session.save(new Cat("Kitty", 3, Color.BLACK)); - session.save(new Cat("Bobby", 4, Color.BLACK)); - session.save(new Cat("Harold", 5, Color.BLACK)); - session.save(new Cat("Tim", 6, Color.BLACK)); + session.persist(new Cat("Beck", 1, Color.BLACK)); + session.persist(new Cat("Kate", 2, Color.BLACK)); + session.persist(new Cat("Kitty", 3, Color.BLACK)); + session.persist(new Cat("Bobby", 4, Color.BLACK)); + session.persist(new Cat("Harold", 5, Color.BLACK)); + session.persist(new Cat("Tim", 6, Color.BLACK)); session.flush(); } } diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/IntegrationBase.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/IntegrationBase.java index 3aef7b0cb..ec9c5b8cc 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/IntegrationBase.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/IntegrationBase.java @@ -98,8 +98,8 @@ private HibernateInsertClause insert(EntityPath entity) { @Test public void scroll() { - session.save(new Cat("Bob", 10)); - session.save(new Cat("Steve", 11)); + session.persist(new Cat("Bob", 10)); + session.persist(new Cat("Steve", 11)); var cat = QCat.cat; HibernateQuery query = new HibernateQuery(session); @@ -112,7 +112,7 @@ public void scroll() { @Test public void insert() { - session.save(new Cat("Bob", 10)); + session.persist(new Cat("Bob", 10)); var cat = QCat.cat; var amount = insert(cat).set(cat.name, "Bobby").set(cat.alive, false).execute(); @@ -123,7 +123,7 @@ public void insert() { @Test public void insert2() { - session.save(new Cat("Bob", 10)); + session.persist(new Cat("Bob", 10)); var cat = QCat.cat; var amount = insert(cat).columns(cat.name, cat.alive).values("Bobby", false).execute(); @@ -134,7 +134,7 @@ public void insert2() { @Test public void insert3() { - session.save(new Cat("Bob", 10)); + session.persist(new Cat("Bob", 10)); var cat = QCat.cat; var bob = new QCat("Bob"); @@ -151,8 +151,8 @@ public void insert3() { @Test public void update() { - session.save(new Cat("Bob", 10)); - session.save(new Cat("Steve", 11)); + session.persist(new Cat("Bob", 10)); + session.persist(new Cat("Steve", 11)); var cat = QCat.cat; var amount = @@ -168,8 +168,8 @@ public void update() { @Test public void update_with_null() { - session.save(new Cat("Bob", 10)); - session.save(new Cat("Steve", 11)); + session.persist(new Cat("Bob", 10)); + session.persist(new Cat("Steve", 11)); var cat = QCat.cat; var amount = @@ -183,8 +183,8 @@ public void update_with_null() { @Test public void delete() { - session.save(new Cat("Bob", 10)); - session.save(new Cat("Steve", 11)); + session.persist(new Cat("Bob", 10)); + session.persist(new Cat("Steve", 11)); var cat = QCat.cat; var amount = delete(cat).where(cat.name.eq("Bob")).execute(); @@ -195,7 +195,7 @@ public void delete() { public void collection() throws Exception { List cats = Arrays.asList(new Cat("Bob", 10), new Cat("Steve", 11)); for (Cat cat : cats) { - session.save(cat); + session.persist(cat); } query().from(cat).innerJoin(cat.kittens, kitten).where(kitten.in(cats)).parse(); diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/UniqueResultsTest.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/UniqueResultsTest.java index 5fdf89857..778de18ed 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/UniqueResultsTest.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/UniqueResultsTest.java @@ -32,9 +32,9 @@ public class UniqueResultsTest implements HibernateTest { @Test public void test() { - session.save(new Cat("Bob1", 1)); - session.save(new Cat("Bob2", 2)); - session.save(new Cat("Bob3", 3)); + session.persist(new Cat("Bob1", 1)); + session.persist(new Cat("Bob2", 2)); + session.persist(new Cat("Bob3", 3)); assertThat( query() diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java index c88a2ffdc..5ffe87e7a 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java @@ -53,9 +53,10 @@ public abstract class AbstractR2DBCDeleteClause entity; diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLiteTemplates.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLiteTemplates.java index 8fc80247d..edc2a8cbd 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLiteTemplates.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLiteTemplates.java @@ -113,8 +113,10 @@ public SQLiteTemplates(char escape, boolean quote) { add( Ops.DateTimeOps.YEAR_MONTH, - "cast(strftime('%Y',{0} / 1000, 'unixepoch', 'localtime') * 100 + strftime('%m',{0} / 1000," - + " 'unixepoch', 'localtime') as integer)"); + """ + cast(strftime('%Y',{0} / 1000, 'unixepoch', 'localtime') * 100 + strftime('%m',{0} / 1000,\ + 'unixepoch', 'localtime') as integer)\ + """); add( Ops.DateTimeOps.YEAR_WEEK, "cast(strftime('%Y%W',{0} / 1000, 'unixepoch', 'localtime') as integer)"); diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLDeleteClause.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLDeleteClause.java index d11cedbc8..9cb702c1f 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLDeleteClause.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLDeleteClause.java @@ -53,9 +53,10 @@ public abstract class AbstractSQLDeleteClause entity; diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/hibernate/HibernateConfiguration.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/hibernate/HibernateConfiguration.java index fb20ba2af..4a7ec9eb2 100644 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/hibernate/HibernateConfiguration.java +++ b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/hibernate/HibernateConfiguration.java @@ -47,7 +47,7 @@ public HibernateConfiguration( protected List> getAnnotations() { try { List> annotations = new ArrayList<>(super.getAnnotations()); - for (String simpleName : Arrays.asList("Type", "Cascade", "LazyCollection", "OnDelete")) { + for (String simpleName : Arrays.asList("Type", "Cascade", "OnDelete")) { annotations.add( (Class) Class.forName("org.hibernate.annotations." + simpleName)); } diff --git a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/InterfaceType2Test.java b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/InterfaceType2Test.java index db2833b50..4a2079a24 100644 --- a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/InterfaceType2Test.java +++ b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/InterfaceType2Test.java @@ -49,8 +49,6 @@ public void setId(Long id) { @Entity @Table(name = "USERS") - // @org.hibernate.annotations.AccessType("field") - @org.hibernate.annotations.Proxy(proxyClass = User.class) public static class UserImpl extends EntityImpl implements User { @NaturalId(mutable = true) @@ -85,8 +83,6 @@ public void setParty(Party party) { @jakarta.persistence.Entity @Table(name = "PARTY") - // @org.hibernate.annotations.AccessType("field") - @org.hibernate.annotations.Proxy(proxyClass = Party.class) public abstract static class PartyImpl extends EntityImpl implements Party { @Column(name = "NAME", nullable = false)