jpa-2.0

Using UUID with EclipseLink and PostgreSQL

强颜欢笑 提交于 2019-12-01 05:38:47
问题 I want to use the PostgreSQL uuid type for objects' primary keys. For that I've created a converter (implementing the Converter interface). Bellow is the relevant code: @Override public void initialize(DatabaseMapping mapping, Session session) { final DatabaseField field; if (mapping instanceof DirectCollectionMapping) { field = ((DirectCollectionMapping) mapping).getDirectField(); } else { field = mapping.getField(); } field.setSqlType(Types.OTHER); field.setTypeName("uuid"); field

How do I write a JPA criteria query that matches a collection exactly?

一笑奈何 提交于 2019-12-01 05:31:16
问题 I’m using JPA 2.0 with Hibernate 4.1.0.Final. I have a couple of classes, Groups and GroupMembers. Each GroupMember is tied to a user object @Entity @Table(name = "group") public class Group { @Id @NotNull @GeneratedValue(generator = "uuid-strategy") @Column(name = "ID") private String id; … @OneToMany(mappedBy = "group") private Set<GroupMember> members; @Entity @Table(name = "sb_msg_group_member") public class GroupMember { … @ManyToOne @JoinColumn(name = "USER_ID", nullable = false,

Why the compiler doesn't recognize the metamodel attributes?

别说谁变了你拦得住时间么 提交于 2019-12-01 05:17:24
Is the criteria api of eclipselink jpa2 supported for java se 6 projects? If not, that's my problem. Do I need to specify anything special to the criteria api in the persistence.xml? This is my criteria query: final EntityType<Meaning> Meaning_ = em.getMetamodel().entity(Meaning.class); final CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Integer> cq = cb.createQuery(Integer.class); final Root<Meaning> meng = cq.from(Meaning.class); cq.where(meng.get(Meaning_.lastPublishedDate)); //this attributes are not recognized/found cq.select(meng.get(Meaning_.objId)); // " " TypedQuery

Updating hibernate version manually

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 04:12:20
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; // getters and setters omitted } @Entity public class Qux { @Id private Long id; @OneToOne @JoinColumn

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

我与影子孤独终老i 提交于 2019-12-01 04:08:40
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.QueryException.invalidTableForFieldInExpression(QueryException.java:739) at org.eclipse.persistence

JPA 2.0 (logging and tracing through) with Glassfish 3.0.1 and NetBeans 6.9.1:

家住魔仙堡 提交于 2019-12-01 03:43:16
I am using JPA 2.0 ( EclipseLink provider) with Glassfish v3.0.1 and NetBeans 6.9.1 and am NOT able to see the queries and other logging information from JPA 2.0. Essentially I want to be able to see all the SQL statements which are being generated by JPA and other related debugging information... Has anyone successfully been able to configure the logging to provide such feedback? I've tried several things to no avail... Any help would be greatly appreciated. Thanks much. Alex H What eventually had done the trick for me was using: <property name="eclipselink.logging.logger" value="org.eclipse

Configuring persistence and orm with JPA 2

梦想与她 提交于 2019-12-01 03:30:32
问题 I'm having some trouble using Persistence on my jBPM project. My configuration is jBPM 5.4 + Hibernate + JPA 2, and I'm currently setting up the process flow to connect to a DB with persistence, through persistence.xml. I'm just trying to connect the default data source (in the H2 server) with my custom persistence.xml, but I keep getting the same error over and over again: Unknown entity: org.jbpm.persistence.processinstance.ProcessInstanceInfo I've manually added to my src/META-INF folder

C3P0 Configurations! Where and How?

╄→гoц情女王★ 提交于 2019-12-01 03:26:21
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.MySQL5InnoDBDialect"/> <property name="hibernate.show_sql" value="true"/> <property name="bytecode.provider"

JPA composite primary key with null value

你。 提交于 2019-12-01 02:53:41
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() to fetch a row with a null SOURCE_SYSTEM always results in a null being returned. 2: Using em.merge()

Why the compiler doesn't recognize the metamodel attributes?

左心房为你撑大大i 提交于 2019-12-01 02:09:27
问题 Is the criteria api of eclipselink jpa2 supported for java se 6 projects? If not, that's my problem. Do I need to specify anything special to the criteria api in the persistence.xml? This is my criteria query: final EntityType<Meaning> Meaning_ = em.getMetamodel().entity(Meaning.class); final CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Integer> cq = cb.createQuery(Integer.class); final Root<Meaning> meng = cq.from(Meaning.class); cq.where(meng.get(Meaning_.lastPublishedDate));