jpa-2.0

Stakover flow error with Jackson applied on JPA Entities to generate JSON

冷暖自知 提交于 2019-12-02 03:20:06
I have a JPA code with OneToMany relationship. A Customer has a list of Item to check out. However, the code continue to generate StackOverflowError . Once, I had resolved this one by applying @JsonIgnore while fetching the List<Item> from Customer entity. But even that does not seem to work anymore. In Customer class: @OneToMany(mappedBy = "customer", orphanRemoval = true) @JsonIgnore private List<Item> items; In Item class: @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "CUSTOMER_ID", nullable = false) private Customer customer; And CustomerRest class: @Path("customers") public class

how to convert datetime to timestamp in java

廉价感情. 提交于 2019-12-02 02:35:56
forum member I am having one problem with date time in java. Actually I am receiving the startdate in format 2012-02-27T01:10:10 and I want to insert the received date to my database having datetime datatype. Actually I tried to convert the startdate received to datetime by below code String sDate = jsonObject.get("StartDate").toString(); String eDate = jsonObject.get("EndDate").toString(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date startD = sdf.format(sDate); Date endD = sdf.format(eDate); but with the above code only date gets added to my database like 2012-02-27 00:00

HQL with fully qualified class name

不打扰是莪最后的温柔 提交于 2019-12-02 02:05:59
问题 Let's say I have entity Foo like - package com.some.company.model; // imports @Entity public class Foo{ @Id private Long id; // getters / setters and other properties omitted } so while dealing with Entity through HQL I prefer to refer the Entity by fully qualified class name like - entityManager.createQuery(String.format("delete from %s where id = :id", Foo.class.getName())) .setParameter("id", fooId) .executeUpdate(); I noticed one thing in @Entity annotation - the name property has a

eclipselink merge() without initial SELECT

帅比萌擦擦* 提交于 2019-12-02 01:16:50
I am trying to perform a merge(entity) using eclipselink, and I would like to indicate to eclipse if that will be an update or insert, so it does not have to perform the initial select query. Thanks to the progress made in this question , I have the following: UnitOfWorkImpl uow = (UnitOfWorkImpl) ((EntityManagerImpl) em.getDelegate()).getUnitOfWork(); if (dbObj.isInDB()) { uow.updateObject(dbObj); } else { uow.insertObject(dbObj); } However, i get the following: org.eclipse.persistence.exceptions.QueryException: Exception Description: Objects cannot be written during a UnitOfWork, they must

How to validate if a foreign key entry exists?

大城市里の小女人 提交于 2019-12-01 23:41:32
问题 I have foreign key inside my Customer table. @JoinColumn(name = "DISCOUNT_CODE", referencedColumnName = "DISCOUNT_CODE") @ManyToOne(optional = false) private DiscountCode discountCode; I have a form that contains all fields of this table (including the foreign key discountCode and its description from the other table). I want to be able to show a message that this foreign key does not exist in case that the user entered an input that does not exist in the foreign key table. When I onblur this

Why is this JPA 2.0 mapping giving me an error in Eclipse/JBoss Tools?

前提是你 提交于 2019-12-01 23:19:34
I have the following situation: (source: kawoolutions.com ) JPA 2.0 mappings ( It might probably suffice to consider only the Zip and ZipId classes as this is where the error seems to come from ): @Entity @Table(name = "GeoAreas") @Inheritance(strategy = InheritanceType.JOINED) @DiscriminatorColumn(name = "discriminator", discriminatorType = DiscriminatorType.STRING) public abstract class GeoArea implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") protected Integer id; @Column(name = "name") protected String name; ... } @Entity @Table(name =

How to validate if a foreign key entry exists?

孤人 提交于 2019-12-01 20:26:53
I have foreign key inside my Customer table. @JoinColumn(name = "DISCOUNT_CODE", referencedColumnName = "DISCOUNT_CODE") @ManyToOne(optional = false) private DiscountCode discountCode; I have a form that contains all fields of this table (including the foreign key discountCode and its description from the other table). I want to be able to show a message that this foreign key does not exist in case that the user entered an input that does not exist in the foreign key table. When I onblur this field, then I'm retriving its description from the table. How can I show the error message of invalid

Create a JPA Criteria fully dynamically

谁都会走 提交于 2019-12-01 18:20:00
问题 Usually I'm a Hibernate user and for my new project we use JPA 2.0. My DAO receives a Container with a generic. public class Container<T> { private String fieldId; // example "id" private T value; // example new Long(100) T is a Long private String operation; // example ">" // getter/setter } The following lines won't compile: if (">".equals(container.getOperation()) { criteriaBuilder.greaterThan(root.get(container.getFieldId()), container.getValue()); } Because I must specify the type like

eclipse Duplicate generator named “ID_GENERATOR” defined in this persistence unit

拟墨画扇 提交于 2019-12-01 18:13:59
I'm currently having this issue which I don't have before I migrated to eclipse-jee-kepler. What I have: I have 2 classes, base and the extending class: public abstract class BaseEntity implements Serializable { @Id @GeneratedValue(generator = "ID_GENERATOR") @Column(name = "ID") private Long id; } @Entity @Table(name = "CUSTOMER") @SequenceGenerator(name = "ID_GENERATOR", sequenceName = "CUSTOMER_SEQ") public class Customer extends BaseEntity { } Before I don't have this validation error but now eclipse is throwing it. I can compile, build and deploy successfully but the error marker is

JPA2.0 support of custom user-types and second level cache

╄→гoц情女王★ 提交于 2019-12-01 17:49:38
问题 I'm trying to decide whether to switch from having Hibernate sprinkled all over to using JPA2.0 and thus be provider portable. 1.Does JPA2.0 support custom user-types? 2.I'm on the verge of implementing Terracotta as a second-level cache to Hibernate with its clustering abilities mainly in mind. I would imagine, but I don't actually know, that JPA2.0 also defines a spec for second-level cache providers. If I'm right, does Terracotta implement it? (If someone could point me to a getting