hibernate

Hibernate custom query containing GROUPBY and HAVING

白昼怎懂夜的黑 提交于 2021-01-01 09:54:08
问题 So I have two entities with a one-to-many relationship. A form_collection contains multiple form . The form contains a column version which keeps track of the most current form. form +----+-----------------+---------+--------------------+ | id | description_key | version | form_collection_id | +----+-----------------+---------+--------------------+ | 1 | desc1 | 1 | 1 | +----+-----------------+---------+--------------------+ | 2 | desc1 | 2 | 1 | +----+-----------------+---------+------------

Hibernate custom query containing GROUPBY and HAVING

你。 提交于 2021-01-01 09:52:50
问题 So I have two entities with a one-to-many relationship. A form_collection contains multiple form . The form contains a column version which keeps track of the most current form. form +----+-----------------+---------+--------------------+ | id | description_key | version | form_collection_id | +----+-----------------+---------+--------------------+ | 1 | desc1 | 1 | 1 | +----+-----------------+---------+--------------------+ | 2 | desc1 | 2 | 1 | +----+-----------------+---------+------------

Hibernate custom query containing GROUPBY and HAVING

旧城冷巷雨未停 提交于 2021-01-01 09:52:45
问题 So I have two entities with a one-to-many relationship. A form_collection contains multiple form . The form contains a column version which keeps track of the most current form. form +----+-----------------+---------+--------------------+ | id | description_key | version | form_collection_id | +----+-----------------+---------+--------------------+ | 1 | desc1 | 1 | 1 | +----+-----------------+---------+--------------------+ | 2 | desc1 | 2 | 1 | +----+-----------------+---------+------------

How to see the schema sql (DDL) in spring boot?

谁说胖子不能爱 提交于 2020-12-30 07:42:24
问题 How can I see the DDL SQL generated by Hibernate for building the schema from the JPA mappings? I am using the embedded HSQL db. I tried the following and none of them worked in Spring-Boot 1.3.5.RELEASE. Adding the following to application.properties file debug=true spring.jpa.properties.hibernate.show_sql=true Set org.hibernate.SQL level to debug in logback.xml Steps listed at http://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html Those only show me

Hibernate Embedded/Embeddable not null exception

£可爱£侵袭症+ 提交于 2020-12-30 06:43:13
问题 In the owning class: ... @Embedded private LatLon location; ... In the referenced class: @Embeddable public class LatLon implements Serializable { private double lat; private double lon; ... } When I try to save an instance of the owning class with a null value for LatLon : org.hibernate.PropertyValueException: not-null property references a null or transient value: com.*.location . What can I do to allow this value to be null in the owning class? I have tried making it Nullable and that had

Hibernate Embedded/Embeddable not null exception

眉间皱痕 提交于 2020-12-30 06:41:35
问题 In the owning class: ... @Embedded private LatLon location; ... In the referenced class: @Embeddable public class LatLon implements Serializable { private double lat; private double lon; ... } When I try to save an instance of the owning class with a null value for LatLon : org.hibernate.PropertyValueException: not-null property references a null or transient value: com.*.location . What can I do to allow this value to be null in the owning class? I have tried making it Nullable and that had

How to save parent and child in one shot (JPA & Hibernate)

本小妞迷上赌 提交于 2020-12-29 11:57:45
问题 I start showing you my scenario. This is my parent object: @Entity @Table(name="cart") public class Cart implements Serializable{ @GeneratedValue(strategy=GenerationType.IDENTITY) @Id @Column(name="id") private Integer id; @OneToMany(mappedBy="cart", fetch = FetchType.EAGER, cascade = CascadeType.ALL) private List<CartItem> cartItems; ... } This is my child object: @Entity @Table(name="cart_item") public class CartItem implements Serializable{ @GeneratedValue(strategy=GenerationType.IDENTITY)

Slow PostgreSQL query in production - help me understand this explain analyze output

若如初见. 提交于 2020-12-29 04:30:24
问题 I have a query that is taking 9 minutes to run on PostgreSQL 9.0.0 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit This query is automatically generated by hibernate for my application. It's trying to find all of the "teacher members" in a school. A membership is a user with a role in a group. There are several types of groups, but here what matters are schools and services. If someone is a teacher member in a service and a member in this

Slow PostgreSQL query in production - help me understand this explain analyze output

青春壹個敷衍的年華 提交于 2020-12-29 04:27:28
问题 I have a query that is taking 9 minutes to run on PostgreSQL 9.0.0 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit This query is automatically generated by hibernate for my application. It's trying to find all of the "teacher members" in a school. A membership is a user with a role in a group. There are several types of groups, but here what matters are schools and services. If someone is a teacher member in a service and a member in this

Building Dynamic ConstraintViolation Error Messages

£可爱£侵袭症+ 提交于 2020-12-28 20:53:38
问题 I've written a validation annotation implemented by a custom ConstraintValidator . I also want to generate very specific ConstraintViolation objects that use values computed during the validation process during message interpolation. public class CustomValidator implements ConstraintValidator<CustomAnnotation, ValidatedType> { ... @Override public boolean isValid(ValidatedType value, ConstraintValidatorContext context) { // Figure out that the value is not valid. // Now, I want to add a