eclipselink

JPA No transaction is currently active

大兔子大兔子 提交于 2019-12-20 20:27:44
问题 Using JPA with EclipseLink implementation. Code: try{ if(!em.getTransaction().isActive()) em.getTransaction().begin(); System.out.println(2); em.persist(currentUser); System.out.println(3); if (em.getTransaction().isActive()){ System.out.println("IS ACTIVE"); } else { System.out.println("NO ACTIVE"); } em.getTransaction().commit(); System.out.println(4); } catch (Exception e){ completed = false; em.getTransaction().rollback(); System.out.println("ERROR: " + e.getMessage()); } Error: INFO:

Should I let JPA or the database cascade deletions?

安稳与你 提交于 2019-12-20 12:15:42
问题 Let's say we have two entities, A and B. B has a many-to-one relationship to A like follows: @Entity public class A { @OneToMany(mappedBy="a_id") private List<B> children; } @Entity public class B { private String data; } Now, I want to delete the A object and cascade the deletions to all its children (B). There are two ways to do this: 1) Add cascade=CascadeType.ALL, orphanRemoval=true to the OneToMany annotation, letting JPA remove all children before removing the A-object from the database

Eclipselink ignores entity classes with lambda expressions

萝らか妹 提交于 2019-12-20 10:26:37
问题 I am building a java SE 8 (oracle 1.8.0-b129) application with EclipseLink (2.5.1, also tried 2.5.2-M1), and have an Entity class that is simply being ignored by EclipeLink, despite being correctly annotated and referenced in the persistence.xml file. The logs show no mention of the class, no schema gets generated for it, etc. Using the entity gives the 'The abstract schema type is unknown' error. I think I have finally tracked down the cause, and thought I would share. Apparently,

How to silently truncate strings while storing them when they are longer than the column length definition?

空扰寡人 提交于 2019-12-20 09:47:12
问题 I have a web app, using EclipseLink and MySQL for storing data. Some of these data are strings, ie varchars in the DB. In the code of entities, the strings have attributes like this: @Column(name = "MODEL", nullable = true, length = 256) private String model; The database is not created by eclipseLink from the code, but the length matches the varchar length in the DB. When the length of such a string data is greater than the length attribute, an exception is raised during the call to javax

How do you use EclipseLink 2.3 as persistence provider in NB 7?

社会主义新天地 提交于 2019-12-20 06:03:35
问题 I downloaded the latest EclipseLink 2.3 and want to give it a try. But I cannot find a way to choose EclipseLink 2.3 as a persistence provider in NB7. Here's what I did. 1. Go to my project's persistence.xml. In Design view-> Persistence Provider drop down menu -> New Persistence Library 2. I added the EclipseLink 2.3 jar files and gave it a name. 3. Hit OK. Nothing happened. It still shows "EclipseLink (JPA 2.)(Default) as my Persistence Provider. And I cannot find the newly created library

JPQL “NOT MEMBER OF” query using criteria API

你离开我真会死。 提交于 2019-12-20 05:18:18
问题 Given the following JPA annotated entity classes: @Entity @Table("foo") public class Foo { @Id private int id; @Column(name="name") private String name; @ManyToMany @JoinTable(name = "foo_tags", joinColumns = {@JoinColumn(name = "foo")}, inverseJoinColumns = {@JoinColumn(name = "tag")}) private Collection<Tag> tags; ... } @Entity @Table(name = "tag") public class Tag { @Id private String tag; ... } I'm trying to formulate a query to get all Foo instances that lack a given tag. The following

Configure CXF JAX-WS service to work with MOXY

天涯浪子 提交于 2019-12-20 04:50:26
问题 Although I've added a jaxb.properties with MOXY factory and I see that the JAXB was switched to moxy, CXF has a method named createRIContext in the JAXBUtils class which loads hard coded the sun JAXB implementation. Is there a way to override it and use moxy instead? The problematic code is the following: // fall back if we're using another jaxb implementation try { riContext = JAXBUtils.createRIContext(contextClasses .toArray(new Class[contextClasses.size()]), tns); } It loads hard coded the

What collections does jpa return?

旧巷老猫 提交于 2019-12-20 03:56:26
问题 Does JPA ( Eclipselink in this case) always return IndirectList where Entity have a List? Is ok that list or It should be converted to another list( maybe linkedlist)? 回答1: Analysis If we look at EclipseLink's IndirectList's API, it says: To use an IndirectList: declare the appropriate instance variable with type IndirectList (jdk1.1) or Collection/List/Vector (jdk1.2). TopLink will place an IndirectList in the instance variable when the containing domain object is read from the datatabase.

Lucene integration with EclipseLink

 ̄綄美尐妖づ 提交于 2019-12-20 03:51:14
问题 I am trying to use Lucene with EclipseLink, and was wondering if there are any good integration libraries out there? I have seen solar-flare, and it looks lime it might do what I want, but it's out of date (although i have an older version of EclipseLink, I am using 4.10 of Lucene) That may work, but I cant find any documentation, examples or tutorials on how to use it. Any advice would be appreciated (I dont believe we can switch to Hibernate either) Thanks in advance 回答1: If you are ready

How to solve 'no primary key specified' for an Entity that inherits from another Entity (JPA)?

独自空忆成欢 提交于 2019-12-20 03:17:24
问题 I want to have a superclass that is common to all document types: @Entity public abstract class Doc implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) protected long docId; public long getDocId() { return docId; } public void setDocId(long docId) { this.docId = docId; } } And I want to have child classes for each doc type: @Entity @Table(name = "DocTypeA") public class DocTypeA extends Doc implements Serializable { // other child fields } But it gives an error