jpa-2.1

How to map one simple class(not an entity) with dto(Entity) class using jpa

a 夏天 提交于 2019-12-13 03:47:22
问题 I tried @OneToOne Mapping with non @Entity class but it seems i am doing something wrong please help. Here is error log for the following classes. Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.package.model.Hotel.address references an unknown entity: com.package.model.Address Here is my Address.java private String street; private String city; private String state; private int pincode; private String country; private String locationCoordinates; //Getters and

its works but i got org.springframework.orm.jpa.JpaSystemException: More than one row with the given identifier was found error

怎甘沉沦 提交于 2019-12-13 03:45:50
问题 my entity class is mentioned below:- public class ExportOrderInfo implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(name = "CURRENT_ORDER_NUMBER") private Integer currentOrderNumber; @Id @Column(name = "ORG_CODE") private Integer orgCode; @Id @Column(name = "STIR_CD") private Integer stirCd; @Id @Column(name = "EXPIRE_DATE") private Date expireDate; @Column(name = "ENTERPRISE_CODE", insertable = false, updatable = false) private Integer enterpriseCode;

How to call SQL dateAdd method using JPA @Query

99封情书 提交于 2019-12-13 02:46:44
问题 I have to search for row, which is older than 6 months. I have insert time(datetime) as one of the column in my table. if it would have been a sql query, it is straight forward like this :- select * from myTable where insertTime<=dateadd(month, -6, getDate()); But I am using JPA, so I had to write something like this :- select * from myTable where insertTime<=function('DATEADD',month, -6, function('getDate')); I am not sure how to put month paramater in above query. I am getting following

What causes “java.lang.IllegalArgumentException: Can not set java.lang.Integer field”

送分小仙女□ 提交于 2019-12-13 02:04:32
问题 I cannot resolve these new exceptions Can not set java.lang.Integer field GcmRegistraionIdentity.gcmId to GcmRegistraionIdentity org.hibernate.PropertyAccessException: could not get a field value by reflection getter of GcmRegistraionIdentity.gcmId My Dynamic Web Project (Jee7) targeted to GlassFish Server Open Source Edition 4.1 (build 13) Hibernate Hibernate Core {4.3.7.Final} My Persistence.xml <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www

Setting up an Entity not associated to a DB table for getting resultList from a procedure call

无人久伴 提交于 2019-12-13 00:54:04
问题 I am using jpa 2.1 ability to call a MySql procedure using em.createStoredProcedureQuery() . The procedure itself is working and is returning a numbered list of names and email addresses as seen in MySql Workbench : My problem is with setting up the POJO for storing the list of results. My entity class is very basic and has only three properties + the getters/and setters. A three-argument constructor and a toString() method are provided. Note that there is no corresponding table associated to

Using List or Set in JPA 2.1 for multiple columns in same table

ぃ、小莉子 提交于 2019-12-12 05:18:18
问题 I am new with JPA. I am building sample maven project with Wicket-Spring-Hibernate-JPA. I am using Hibernate EntityManager: v4.3.5.Final. I am using JPA: v2.1-api. I am using database mySql: v5.6. When I am writing a model class, I want to map tables multiple columns with an element in model class as List or Set. Database Table Name: QUESTION_MAIN Column Name : Type : PK QID : int : PK QTYPE : varchar QUESTION : varchar OPTION1 : varchar OPTION2 : varchar OPTION3 : varchar OPTION4 : varchar

How to use mappedBy with more than one value JPA

别说谁变了你拦得住时间么 提交于 2019-12-12 02:53:17
问题 I have 2 tables: Currency and Rate The currency's primary key is referenced by the inputCurrency and outputCurrency foreigh keys in the Rate. How can I map these in order to cascadeALL? I tried in Rate (the table that contains the foreigh keys) @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "INPUT_CURRENCY") private Currency inputCurrency; @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "OUTPUT_CURRENCY") private Currency ouputCurrency; But if I delete an item from currency

@Convert in Hibernate not working with spring 4,java.lang.NoSuchMethodError: org.hibernate.cfg.Configuration.addAttributeConverter(Ljava/lang/Class;)V

你离开我真会死。 提交于 2019-12-12 01:45:37
问题 <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.aratan.myapp</groupId> <artifactId>reporting-module</artifactId> <version>A1</version> <packaging>war</packaging> <build> <finalName>reporting-module</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven

Best way to get aggregate function result inside the entity object

血红的双手。 提交于 2019-12-11 19:42:51
问题 Many time I have to get the SQL aggregate query result inside the Entity Object itself. As of now I could able to achive the same by the following code CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Tuple> q = cb.createTupleQuery(); Root<Test> c = q.from(Test.class); q.multiselect(c, cb.count(c)); q.groupBy(c.get("type")); TypedQuery<Tuple> t = em.createQuery(q); List<Tuple> resultList = t.getResultList(); List<Test> list = new ArrayList<>(); for(Tuple tuple : resultList){ Test

EclipseLink fails to fetch a scalar Boolean value

一曲冷凌霜 提交于 2019-12-11 12:19:54
问题 The following JPA criteria query succeeds on Hibernate (4.2.7 final). CriteriaBuilder criteriaBuilder=entityManager.getCriteriaBuilder(); CriteriaQuery<Boolean>criteriaQuery=criteriaBuilder.createQuery(Boolean.class); Root<UserTable> root = criteriaQuery.from(entityManager.getMetamodel().entity(UserTable.class)); criteriaQuery.multiselect(root.get(UserTable_.enabled)); ParameterExpression<String>parameterExpression=criteriaBuilder.parameter(String.class); criteriaQuery.where(criteriaBuilder