Package io.quarkus.hibernate.panache
package io.quarkus.hibernate.panache
API usage
Hibernate with Panache comes in two flavors, the active record pattern viainvalid reference
io.quarkus.hibernate.orm.panache.PanacheEntity
invalid reference
io.quarkus.hibernate.orm.panache.PanacheRepository
invalid reference
io.quarkus.hibernate.orm.panache.PanacheEntity
@Entity
public class Person extends PanacheEntity {
public String name;
public LocalDate birth;
public PersonStatus status;
public static Person findByName(String name){
return find("name", name).firstResult();
}
public static List<Person> findAlive(){
return list("status", Status.Alive);
}
public static void deleteStefs(){
delete("name", "Stef");
}
}
To use the repository pattern, create a class implementing
invalid reference
io.quarkus.hibernate.orm.panache.PanacheRepository
@ApplicationScoped
public class PersonRepository implements PanacheRepository<Person> {
public Person findByName(String name){
return find("name", name).firstResult();
}
public List<Person> findAlive(){
return list("status", Status.Alive);
}
public void deleteStefs(){
delete("name", "Stef");
}
}
Simplified queries
Normally, HQL queries are of this form: from EntityName [where ...] [order by ...], with optional elements
at the end.
If your select query does not start with from, select, or with, we support the
following additional forms:
order by ...which will expand tofrom EntityName order by ...<singleAttribute>(and single parameter) which will expand tofrom EntityName where <singleAttribute> = ?where <query>will expand tofrom EntityName where <query><query>will expand tofrom EntityName where <query>
If your update query does not start with update from, we support the following additional forms:
from EntityName ...which will expand toupdate from EntityName ...set? <singleAttribute>(and single parameter) which will expand toupdate from EntityName set <singleAttribute> = ?set? <update-query>will expand toupdate from EntityName set <update-query> = ?
If your delete query does not start with delete from, we support the following additional forms:
from EntityName ...which will expand todelete from EntityName ...<singleAttribute>(and single parameter) which will expand todelete from EntityName where <singleAttribute> = ?<query>will expand todelete from EntityName where <query>
- Author:
- Stéphane Épardaud
-
ClassDescriptionJakarta Data static metamodel for
WithIdUtility class for Panache.This is just an alias forPanacheManagedBlockingEntityandWithId.AutoLongfor people coming from Panache 1Represents an entity with managed blocking operations.Represents an entity with managed reactive operations.Represents an entity with stateless reactive operations.Represents an entity with stateless blocking operations.This is just an alias forPanacheManagedBlockingEntityfor people coming from Panache 1PanacheQuery<Entity,EntityList, Confirmation, Count> PanacheRepository<Entity>PanacheRepository.Managed<Entity,Id> PanacheRepository.Reactive<Entity,Id> PanacheRepository.Reactive.Stateless<Entity,Id> PanacheRepository.Stateless<Entity,Id> PanacheRepositoryQueries<Entity,EntityList, Query extends PanacheQuery<?, ?, ?, ?>, Count, Confirmation, Id> PanacheRepositorySwitcher<Entity,Id> WithId<IdType>Static metamodel forWithId