Skip to content
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 @@ -502,4 +502,9 @@ public CacheMode getCacheMode() {
public void setCacheMode(CacheMode cacheMode) {
delegate.get().setCacheMode(cacheMode);
}

@Override
public <T> T unwrap(Class<T> type) {
return delegate.get().unwrap(type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -875,4 +875,15 @@ public void setCacheMode(CacheMode cacheMode) {
emr.statelessSession.setCacheMode(cacheMode);
}
}

@Override
public <T> T unwrap(Class<T> type) {
if (type.isAssignableFrom(StatelessSession.class)) {
return (T) this;
}
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.statelessSession.unwrap(type);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.List;

import jakarta.data.Order;
import jakarta.data.Sort;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
Expand Down Expand Up @@ -30,6 +32,11 @@ public void create(MyEntity entity) {
repository.insert(entity);
}

@GET
public List<MyEntity> get() {
return repository.findAll(Order.by(Sort.asc(MyEntity_.NAME))).toList();
}

@GET
@Transactional
@Path("/by/name/{name}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package io.quarkus.it.hibernate.jpamodelgen.data;

import java.util.List;
import java.util.stream.Stream;

import jakarta.data.Order;
import jakarta.data.repository.CrudRepository;
import jakarta.data.repository.Delete;
import jakarta.data.repository.Find;
import jakarta.data.repository.Query;
import jakarta.data.repository.Repository;

@Repository
public interface MyRepository extends CrudRepository<MyEntity, Integer> {

@Find
Stream<MyEntity> findAll(Order<MyEntity> order);

@Query("select e from MyEntity e where e.name like :name")
List<MyEntity> findByName(String name);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.quarkus.it.hibernate.jpamodelgen.data;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;

import org.junit.jupiter.api.Test;

Expand All @@ -20,6 +22,12 @@ public void staticMetamodel() {
.when().get(ROOT + "/by/name/{name}")
.then()
.statusCode(404);
given()
.contentType(ContentType.JSON)
.when().get(ROOT)
.then()
.statusCode(200)
.body(equalTo("[]"));
given()
.body(new MyEntity("foo"))
.contentType(ContentType.JSON)
Expand All @@ -32,6 +40,12 @@ public void staticMetamodel() {
.when().get(ROOT + "/by/name/{name}")
.then()
.statusCode(200);
given()
.contentType(ContentType.JSON)
.when().get(ROOT)
.then()
.statusCode(200)
.body(containsString("\"foo\""));

// Update
given()
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<jacoco.version>0.8.13</jacoco.version>
<kubernetes-client.version>7.3.1</kubernetes-client.version> <!-- Please check with Java Operator SDK team before updating -->
<rest-assured.version>5.5.5</rest-assured.version>
<hibernate-orm.version>7.0.1.Final</hibernate-orm.version> <!-- WARNING when updating, also align the versions below -->
<hibernate-orm.version>7.0.2.Final</hibernate-orm.version> <!-- WARNING when updating, also align the versions below -->
<jakarta.persistence-api.version>3.2.0</jakarta.persistence-api.version> <!-- version controlled by Hibernate ORM's needs -->
<antlr.version>4.13.0</antlr.version> <!-- version controlled by Hibernate ORM's needs -->
<bytebuddy.version>1.15.11</bytebuddy.version> <!-- version controlled by Hibernate ORM's needs -->
Expand Down
Loading