Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the proper PU for executeUpdate on entityClass #42400

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ public int executeUpdate(Class<?> entityClass, String panacheQuery, Object... pa

try {
String updateQuery = PanacheJpaUtil.createUpdateQuery(entityClass, panacheQuery, paramCount(params));
return bindParameters(getSession(DEFAULT_PERSISTENCE_UNIT_NAME).createMutationQuery(updateQuery), params)
return bindParameters(getSession(entityClass).createMutationQuery(updateQuery), params)
.executeUpdate();
} catch (RuntimeException x) {
throw NamedQueryUtil.checkForNamedQueryMistake(x, panacheQuery);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.quarkus.it.panache.custompu;

import jakarta.persistence.Entity;

import io.quarkus.hibernate.orm.panache.PanacheEntity;

@Entity
public class CustomPuEntity extends PanacheEntity {
public String string;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;
import jakarta.persistence.Transient;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.enterprise.context.ApplicationScoped;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;
import jakarta.transaction.Transactional;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.enterprise.context.ApplicationScoped;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.enterprise.context.ApplicationScoped;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import io.quarkus.hibernate.orm.panache.PanacheRepository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.enterprise.context.ApplicationScoped;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;
import jakarta.persistence.ManyToOne;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import io.quarkus.hibernate.orm.panache.common.ProjectedFieldName;
import io.quarkus.runtime.annotations.RegisterForReflection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import io.quarkus.runtime.annotations.RegisterForReflection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.enterprise.context.ApplicationScoped;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import io.quarkus.hibernate.orm.panache.common.ProjectedFieldName;
import io.quarkus.runtime.annotations.RegisterForReflection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import io.quarkus.hibernate.orm.panache.common.NestedProjectedClass;
import io.quarkus.runtime.annotations.RegisterForReflection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.enterprise.context.ApplicationScoped;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.MappedSuperclass;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;
import jakarta.xml.bind.annotation.XmlAccessType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;
import jakarta.persistence.NamedQuery;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.NamedQuery;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.enterprise.context.ApplicationScoped;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;
import jakarta.persistence.NamedQuery;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.enterprise.context.ApplicationScoped;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.transaction.Transactional;
import jakarta.ws.rs.GET;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import java.io.Serializable;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import java.io.Serializable;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Entity;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import io.quarkus.hibernate.orm.panache.common.NestedProjectedClass;
import io.quarkus.hibernate.orm.panache.common.ProjectedFieldName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Embeddable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Embeddable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import io.quarkus.runtime.annotations.RegisterForReflection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

public enum Status {
LIVING,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand Down Expand Up @@ -1266,7 +1266,7 @@ public String testProjection() {
Assertions.assertEquals("2", person.name);

person = Person.find(String.format(
"select uniqueName, name%sfrom io.quarkus.it.panache.Person%swhere name = ?1",
"select uniqueName, name%sfrom io.quarkus.it.panache.defaultpu.Person%swhere name = ?1",
LINE_SEPARATOR, LINE_SEPARATOR), "2")
.project(PersonName.class)
.firstResult();
Expand Down Expand Up @@ -1374,8 +1374,8 @@ public String testNestedProjection() {
person.persist();
PersonDTO personDTO = Person.find(
"select uniqueName, name, " +
" new io.quarkus.it.panache.PersonDTO$AddressDTO(address.street)," +
" new io.quarkus.it.panache.PersonDTO$DescriptionDTO(description.size, description.weight)," +
" new io.quarkus.it.panache.defaultpu.PersonDTO$AddressDTO(address.street)," +
" new io.quarkus.it.panache.defaultpu.PersonDTO$DescriptionDTO(description.size, description.weight)," +
" description.size" +
" from Person2 where name = ?1",
"2n")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache;
package io.quarkus.it.panache.defaultpu;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.panache.fk.issue35812;
package io.quarkus.it.panache.defaultpu.fk.issue35812;

import jakarta.persistence.Entity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;

import io.quarkus.it.panache.Book;
import io.quarkus.it.panache.BookDao;
import io.quarkus.it.panache.defaultpu.Book;
import io.quarkus.it.panache.defaultpu.BookDao;

@Path("/book")
public class BookResource {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.quarkus.it.panache.resources;

import java.util.List;

import jakarta.transaction.Transactional;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;

import io.quarkus.it.panache.custompu.CustomPuEntity;

@Path("/custom-pu")
public class CustomPuResource {

@Transactional
@POST
@Path("/{string}")
public CustomPuEntity create(@PathParam("string") String string) {
CustomPuEntity entity = new CustomPuEntity();
entity.string = string;
entity.persist();
return entity;
}

@Transactional
@PATCH
@Path("/{string}")
public List<CustomPuEntity> updateAll(@PathParam("string") String string) {
CustomPuEntity.update("set string = ?1 where 1 = 1", string);
return CustomPuEntity.findAll().list();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import io.quarkus.it.panache.UserRepository;
import io.quarkus.it.panache.defaultpu.UserRepository;

@Path("/users")
@Produces(MediaType.APPLICATION_JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test
quarkus.datasource.jdbc.max-size=8

quarkus.hibernate-orm.packages=io.quarkus.it.panache.defaultpu
quarkus.hibernate-orm.database.generation=drop-and-create

quarkus.hibernate-orm.statistics=true
quarkus.hibernate-orm.metrics.enabled=true

quarkus.datasource."custom".db-kind=h2
quarkus.datasource."custom".jdbc.url=jdbc:h2:tcp://localhost/mem:test
quarkus.datasource."custom".jdbc.max-size=8

quarkus.hibernate-orm."custom".datasource=custom
quarkus.hibernate-orm."custom".packages=io.quarkus.it.panache.custompu
quarkus.hibernate-orm."custom".database.generation=drop-and-create
quarkus.hibernate-orm."custom".database.generation.create-schemas=true
Loading
Loading