jpa-2.1

Error when trying to insert an extended entity: invalid column index

白昼怎懂夜的黑 提交于 2019-12-11 10:28:06
问题 I have two entities for two classes. First is an extended class of the second (Observer pattern): The child: @Entity @Inheritance(strategy = InheritanceType.JOINED) @DiscriminatorValue("User") @Table(name="SCH.USER") public class User extends Observer implements Serializable{ ...fields... } And the father: @Entity @Inheritance(strategy = InheritanceType.JOINED) @DiscriminatorColumn(name = "DISCRIMINATOR", discriminatorType = DiscriminatorType.STRING) @Table(name="SCH.OBSERVER") public

QuerySyntaxException: expecting CLOSE, found '.'

青春壹個敷衍的年華 提交于 2019-12-11 07:46:02
问题 I want to rewrite this SQL query into JPQL and use JPA Projection: SELECT count(id) as count, status, error_class, error_message, id, settlement_status_raw FROM `payment_transactions` WHERE `payment_transactions`.`terminal_id` = 16 AND (created_at > '2019-06-01 00:00:00.000000') AND (`payment_transactions`.`status` != 'approved') GROUP BY `payment_transactions`.`error_message` ORDER BY count DESC I tried this: @Query(value = "SELECT new org.plugin.service.PaymentTransactionsDeclineReasonsDTO

Why do subqueries with nested properties in EclipseLink always produce an unnecessary/redundant/duplicate/superfluous join?

旧时模样 提交于 2019-12-11 03:52:03
问题 I wanted to generate the following SQL through EclipseLink (2.6.1) JPA criteria. SELECT zonecharge0_.charge AS col_0_0_ FROM projectdb.zone_charge zonecharge0_ WHERE ( EXISTS ( SELECT country1_.country_id FROM projectdb.country country1_ WHERE country1_.country_id=? and zonecharge0_.zone_id=country1_.zone_id ) ) AND ( zonecharge0_.weight_id IN ( SELECT MAX(weight2_.weight_id) FROM projectdb.weight weight2_ WHERE weight2_.weight BETWEEN 0 AND 60 ) ) Running both of the following criteria and

org.hibernate.MappingException despite JPA Converter is available

安稳与你 提交于 2019-12-11 02:27:55
问题 I've got a own Id type public class Id<T extends AbstractEntity<T>> {} and a JPA Attribute Converter: @Converter(autoApply = true) public class IdConverter<T extends Entity<T>> implements AttributeConverter<Id, Long> { //... } despite that I use @Converter(autoApply = true) and @Convert(...) at the property, I get a mapping exception when I start my application using Hibernate 4.3.7: org.hibernate.MappingException: Could not determine type for: com.bosch.si.acm.persistence.domain.Id, at table

How not to roll back previous methods persist data?

≡放荡痞女 提交于 2019-12-11 02:09:43
问题 My DAO interface is simple: import org.springframework.transaction.annotation.Transactional; @Component @Transactional public interface TTestDao { @Transactional() public void first(); @Transactional(propagation=Propagation.REQUIRES_NEW) public void second() ; } ad impl methods: @Override public void first() { entityManager.persist(new TableTest1().setName("data1")); this.second(); } public void second() { entityManager.persist(new TableTest1().setName("data2")); throw new RuntimeException();

How to use JPA - EntityGraph to load only a subset of entity @Basic attributes?

孤人 提交于 2019-12-10 11:13:49
问题 I found this documentation about entity-graphs... after read it, it gave me the idea that you can used entity-graphs to retrieve only a subset of @Basic fields of a given entity (Until now, I have used entity-graphs to retrieve relationships EAGERLY, i.e, for example, load an Employee[including all its attributes] and its associated Department[including all its attributes])... So, I decided to try this using a small test: @Entity @Table(name = "employee") @NamedEntityGraphs({

JPA 2.1: Introducing Java 8 Date/Time API

旧城冷巷雨未停 提交于 2019-12-10 02:11:55
问题 I'd like to add support for the Java 8 Date/Time API (JSR-310) in my JPA-enabled application. It's clear that JPA 2.1 does not support the Java 8 Date/Time API. As a workaround, the most common advise is to use an AttributeConverter. In my existing application, I changed my entities to use LocalDate / LocalDateTime types for the column mapping fields and added legacy setter/getters for java.util.Date to them. I created corresponding AttributeConverter classes. My application does now fail

@OnDelete Hibernate annotation does not generate ON DELETE CASCADE for MySql

若如初见. 提交于 2019-12-09 20:00:45
问题 I have two entities parent and child with a unidirectional relationship class Parent { @Id @GeneratedValue(strategy= GenerationType.AUTO) private Long id; } and class Child { @Id @GeneratedValue(strategy= GenerationType.AUTO) private Long id; @ManyToOne(optional = false) @JoinColumn(name = "parent_id") @OnDelete(action = OnDeleteAction.CASCADE) private Parent parent; } In the application.properties file I have configured spring.jpa.properties.hibernate.dialect = org.hibernate.dialect

Migrating to Hibernate 5.x

拜拜、爱过 提交于 2019-12-09 19:24:30
问题 I am migrating my application to Hibernate 5 from Hibernate 3. We are using DatabaseMetadata class to get TableMetadata . Hence using TableMetadata object to get DB table column information like column size, type..etc. It seems in Hibernate 5 DatabaseMetadata class got deprecated (removed!). Are there any alternatives for DatabaseMetadata class in Hibernate 5? Or else how to get TableMetadata in Hibernate 5 env? 回答1: It got removed in 5.0 as we moved to a new approach to schema tooling.

JPA: java.lang.StackOverflowError on adding toString method in entity classes

狂风中的少年 提交于 2019-12-09 18:01:34
问题 Everything worked fine until I added toSting() in my entity classes. After which I start getting the following error in runtime: Exception in thread "main" java.lang.StackOverflowError at java.lang.AbstractStringBuilder.append(Unknown Source) at java.lang.StringBuilder.append(Unknown Source) at java.lang.StringBuilder.<init>(Unknown Source) at entity.Guide.toString(Guide.java:51) at java.lang.String.valueOf(Unknown Source) at java.lang.StringBuilder.append(Unknown Source) at entity.Student