Hibernate (Java): Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(→Links) |
|||
(7 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 14: | Zeile 14: | ||
== Hibernate 5 == | == Hibernate 5 == | ||
=== Links === | === Annotations === | ||
==== Links ==== | |||
[https://howtodoinjava.com/hibernate/hibernate-jpa-2-persistence-annotations-tutorial https://howtodoinjava.com/hibernate/hibernate-jpa-2-persistence-annotations-tutorial] | [https://howtodoinjava.com/hibernate/hibernate-jpa-2-persistence-annotations-tutorial https://howtodoinjava.com/hibernate/hibernate-jpa-2-persistence-annotations-tutorial] | ||
[https://www.thoughts-on-java.org/mapping-definitions-jpa-hibernate-annotations-xml/ https://www.thoughts-on-java.org/mapping-definitions-jpa-hibernate-annotations-xml/] | [https://www.thoughts-on-java.org/mapping-definitions-jpa-hibernate-annotations-xml/ https://www.thoughts-on-java.org/mapping-definitions-jpa-hibernate-annotations-xml/] | ||
=== count result === | |||
<pre> | |||
CriteriaBuilder builder = sessionFactory.getCurrentSession().getCriteriaBuilder(); | |||
CriteriaQuery<Long> query = builder.createQuery(Long.class); | |||
Root<Entity> root = query.from(Entity.class); | |||
query.select(builder.count(root)); | |||
query.where(builder.and(builder.equal(root.get("status"), "A"))); | |||
return sessionFactory.getCurrentSession().createQuery(query).getSingleResult(); | |||
</pre> | |||
=== Object-Relational Mapping === | |||
==== Links ==== | |||
[http://webdev.jhuep.com/~jcs/ejava-javaee/coursedocs/605-784-site/docs/content/html/hibernate-migration-orm.html#hibernate-migration-orm-mapping http://webdev.jhuep.com/~jcs/ejava-javaee/coursedocs/605-784-site/docs/content/html/hibernate-migration-orm.html#hibernate-migration-orm-mapping] | |||
[https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/task_manage_orm.htm https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/task_manage_orm.htm] | |||
[https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/concepts001.htm#CHDBIJAC https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/concepts001.htm#CHDBIJAC] | |||
=== Projections === | |||
==== Result Transformer ==== | |||
in Hibernate 6 <code>org.hibernate.query.Query.setResultTransformer()</code> will be replaced by <code>@FunctionalInterface</code>: | |||
Quelle: [http://wiki.openbravo.com/wiki/Hibernate_5.3_Migration_Guide http://wiki.openbravo.com/wiki/Hibernate_5.3_Migration_Guide] | |||
==== Links ==== | |||
[https://www.objectdb.com/java/jpa/query/jpql/select https://www.objectdb.com/java/jpa/query/jpql/select] | |||
Zurück zu [[Java#Frameworks|Java]] | Zurück zu [[Java#Frameworks|Java]] |
Aktuelle Version vom 30. Dezember 2018, 16:53 Uhr
Hibernate 2
Sub Query
ExtendedDetachedCriteria voucherCriteria = ExtendedDetachedCriteria.forClass(DocumentParameters.class); voucherCriteria.setProjection(Projections.property("targetVoucherType")); voucherCriteria.add(Restrictions.eq("client", client)); ExtendedDetachedCriteria invoiceCriteria = ExtendedDetachedCriteria.forClass(IncomingInvoice.class); invoiceCriteria.add(Subqueries.propertyIn("voucherType", voucherCriteria));
Hibernate 5
Annotations
Links
https://howtodoinjava.com/hibernate/hibernate-jpa-2-persistence-annotations-tutorial
https://www.thoughts-on-java.org/mapping-definitions-jpa-hibernate-annotations-xml/
count result
CriteriaBuilder builder = sessionFactory.getCurrentSession().getCriteriaBuilder(); CriteriaQuery<Long> query = builder.createQuery(Long.class); Root<Entity> root = query.from(Entity.class); query.select(builder.count(root)); query.where(builder.and(builder.equal(root.get("status"), "A"))); return sessionFactory.getCurrentSession().createQuery(query).getSingleResult();
Object-Relational Mapping
Links
https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/task_manage_orm.htm
https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/concepts001.htm#CHDBIJAC
Projections
Result Transformer
in Hibernate 6 org.hibernate.query.Query.setResultTransformer()
will be replaced by @FunctionalInterface
:
Quelle: http://wiki.openbravo.com/wiki/Hibernate_5.3_Migration_Guide
Links
https://www.objectdb.com/java/jpa/query/jpql/select
Zurück zu Java