jpa-2.0

EclipseLink JPA “invalid table in this context” with @OneToMany Map

て烟熏妆下的殇ゞ 提交于 2019-12-01 01:19:57
问题 I'm hoping I'm just doing something silly here... I'm trying to set up JPA annotations for a Map<String, Phone> and getting the following stack trace. Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.QueryException Exception Description: The field [EMPLOYEE.PHONE_TYPE] in this expression has an invalid table in this context. Query: ReadAllQuery(name="phones" referenceClass=Phone ) at org.eclipse.persistence.exceptions

Updating hibernate version manually

。_饼干妹妹 提交于 2019-12-01 01:12:41
问题 I have two classes say Foo and Bar mapped as @OneToOne (bidirectional) using Hibernate (3.6.1 final) with JPA (2.0) like - @Entity public class Foo{ @Id private Long id; @OneToOne(cascade = CascadeType.ALL, mappedBy = "foo") private Bar bar; @OneToOne(cascade = CascadeType.ALL, mappedBy = "foo") private Qux qux; @Version private int version; // getters and setters omitted } @Entity public class Bar{ @Id private Long id; @OneToOne @JoinColumn(name = "foo_id", nullable = false) private Foo foo;

C3P0 Configurations! Where and How?

和自甴很熟 提交于 2019-11-30 23:53:30
问题 We are implementing a Web App using JPA2.0 and Hibernate3.0. Connection pool configurations are set in persistence.xml located in META-INF folder. persistence.xml: <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"> <persistence-unit name="MyPU" transaction-type="RESOURCE_LOCAL"> <!-- Entity Classes--> <properties> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <property name="hibernate.dialect" value="org.hibernate.dialect

JPA: Why the annotations are applied on getter or field

放肆的年华 提交于 2019-11-30 23:52:10
why the jpa annotations are applied on field or on getter methods. if i try to apply the annotations on setter method then compiler generate the error. because compiler ignore the annotation on setter method. what is the reason behind them? Yogendra Singh This is is how it's specified. Per JPA Specification : When field-based access is used, the object/relational mapping annotations for the entity class annotate the instance variables, and the persistence provider runtime accesses instance variables directly. All non-transient instance variables that are not annotated with the Transient

JPA composite primary key with null value

孤者浪人 提交于 2019-11-30 23:48:52
问题 I have a table containing customer data in an oracle database. Here is a simplified definition: CUSTOMER (CUSTOMER_ID NUMBER NOT NULL, SOURCE_SYSTEM VARCHAR2(30), FULL_NAME VARCHAR2(360), PHONE_NUMBER VARCHAR2(240) ) The primary key for this table is (CUSTOMER_ID, SOURCE_SYSTEM) . The table has numerous rows for which SOURCE_SYSTEM is null. At the database level, there is no issue, however when I try to access any of these rows via JPA Entity, it causes a number of issues: 1: Using em.find()

What's an appropriate DAO structure with jpa2/eclipselink?

こ雲淡風輕ζ 提交于 2019-11-30 21:50:55
I've JPA entities and need to perform logic with them. Until now a huge static database class did the job. It's ugly because every public interface method had an private equivalent that used the EntityManager, to perform transactions. But I could solve that having a static em too! However i'm wondering if that's an appropriate design, especially as the class is responsible for many things. Not surprisingly, the code i found online of real projects was not easy to understand (i might then as well remeain with my code). The code here is easy to understand, although maybe over generic? Anyway, on

JBoss 5.1: Hibernate with JPA

ε祈祈猫儿з 提交于 2019-11-30 20:49:50
I've got two questions to ask regarding JBoss 5.1. We are in process of migrating from JBoss 4.2 to JBoss 5.1. We are also using Java 1.6 and JPA 2.0 with Hibernate 3.6 as the provider. My questions are: Is it possible to use Hibernate 3.6+ with JBoss 5.1. If yes, then how? What about JPA 2.0? I know that JBoss 5.1 comes with JPA 1.0 compatibility. Can we use JPA2? And as we can not do any kind of configuration to the JBoss installation, all the fixes need to be done in our application only. Thanks in advance, JassB Do this: 1) Add jboss-classloading.xml to /src/main/webapp (I am using Maven):

How to check a collection size in JPA2

不打扰是莪最后的温柔 提交于 2019-11-30 20:20:44
Consider the following: @Entity public class Book { private List<String> authors; @ElementCollection public List<String> getAuthors() { return authors; } public void setAuthors(List<String> authors) { this.authors = authors; } } How to type a JPA2 CriteriaQuery expression which, say, will let me find all the Books which have more than 2 authors? JB Nizet In JPQL: select b from Book where size(b.authors) >= 2 Using the criteria API (but why would you replace such a simple static query with the following mess?): CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Book> criteriaQuery = cb

What's an appropriate DAO structure with jpa2/eclipselink?

隐身守侯 提交于 2019-11-30 18:25:15
问题 I've JPA entities and need to perform logic with them. Until now a huge static database class did the job. It's ugly because every public interface method had an private equivalent that used the EntityManager, to perform transactions. But I could solve that having a static em too! However i'm wondering if that's an appropriate design, especially as the class is responsible for many things. Not surprisingly, the code i found online of real projects was not easy to understand (i might then as

EntityManager doesn't refresh the data after querying

百般思念 提交于 2019-11-30 17:15:55
问题 My current project uses HSQLDB2.0 and JPA2.0 . The scenario is: I query DB to get list of contactDetails of person . I delete single contactInfo at UI but do not save that data ( Cancel the saving part). I again do the same query, now the result list is 1 lesser than previous result coz I have deleted one contactInfo at UI. But that contactInfo is still available at DB if I cross check. But if I include entityManager.clear() before start of the query, I get correct results every time. I dont