eclipselink

JPA and database Flex fields

落花浮王杯 提交于 2020-01-02 15:04:26
问题 'Flex fields' is a term for altering a table at the customer site to add extra columns to a table to hold custom pieces of information about that table's entity. I was wondering if anyone has dealt with supporting this mechanism with jpa, specifically eclipselink. We wish to do this because we allow filtering of the base rows based on values in these customer specified fields, and having these fields in an association table causes multiple alias joins to this auxilliary table. An obvious

How do you query the EclipseLink version at runtime (plus JPA meta data)?

巧了我就是萌 提交于 2020-01-02 09:28:34
问题 Question pretty much says it all. Is there an equivalent for org.hibernate.Version.getVersionString() in EclipseLink? Why isn't there a portable (JPA) way to query provider information in general? 回答1: Never used it but from the Eclipselink javadoc you could try the following class: org.eclipse.persistence.Version 回答2: There is a static class and static method to get this information. Example: How to print in java code AbstractSessionLog.getLog().log(SessionLog.INFO, DatabaseLogin.getVersion(

Indexed element access in JPQL

拟墨画扇 提交于 2020-01-02 08:09:12
问题 Is it possible to do indexed element access in JPQL like in HQL : select o from Order o where o.items[0].id = 1234 I couldn't find something related in the JPA 2 specs, I am targeting EclipseLink JPA here, so if you come up with an EclipseLink solution, that's ok as well, although a JPQL standard solution is preferred. 回答1: The INDEX function should do the trick (actually I tested it and it does): SELECT o FROM Order o JOIN o.items i WHERE i.id = 1234 AND INDEX(i) = 0 From the JPA 2.0

Eclipse Warnings: class javax.persistence.* not found

别来无恙 提交于 2020-01-02 07:04:21
问题 This is my first time really playing around with Java development using Eclipse. I am trying to use EclipseLink's implementation of the JPA. I moved all of my entities into a separate package "entities". I have the persistence.xml in a separate JPA project called "dataModeling". Everything builds and runs fine. Just about every project depends on my entities. However, I'm seeing a warning Class javax.persistence.Entity not found - continuing with a stub. , etc. showing up because the

EclipseLink : No Persistence provider for EntityManager named

不问归期 提交于 2020-01-02 03:53:09
问题 I'd like to create one Bundle that is able to use Java Persistence. To achieve this, I've created a plugin project within Eclipse. In my project, I've created a persistence.xml file into META-INF. I've aslo added in my MANIFEST.mf (into the depencies) those 3 packages : javax.persistence.jar org.eclipse.persistence.jar org.eclipse.persistence.jar Then, in my Activator I use this lines to create an EntityManager : factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);

EclipseLink, EntityManager with two persistence units needed

て烟熏妆下的殇ゞ 提交于 2020-01-01 16:58:29
问题 I have one jar library A (or project in eclipse), which has it's own persistence unit (META-INF/persistence.xml) and some entity classes, and another project (B) using this one. In project B there is also persistence unit and entity classes. In project B I need to use both entity classes from project A and B. But if I set "A" as persistence unit name, EntityManager cannot create named query if this query is in entity from project B. If I set "B" as persistence unit name, it cannot create

Why does EntityManager insert instead of updating?

时间秒杀一切 提交于 2020-01-01 08:48:36
问题 I have a main thread where I get an object from database, then close the EntityManager, then put the object into a queue. A worker thread makes some business with the object, then puts it into a finished queue. Then the main thread gets the object from the finished queue and merges the object: EntityManager em = entityManagerFactory.createEntityManager(); em.getTransaction().begin(); // Print the primary key ID of the object, // it is NOT empty yes it exists in the db. em.merge(myObject); em

Why does EntityManager insert instead of updating?

痞子三分冷 提交于 2020-01-01 08:48:14
问题 I have a main thread where I get an object from database, then close the EntityManager, then put the object into a queue. A worker thread makes some business with the object, then puts it into a finished queue. Then the main thread gets the object from the finished queue and merges the object: EntityManager em = entityManagerFactory.createEntityManager(); em.getTransaction().begin(); // Print the primary key ID of the object, // it is NOT empty yes it exists in the db. em.merge(myObject); em

How do I catch the constraint violation exception from EclipseLink?

浪尽此生 提交于 2020-01-01 08:06:07
问题 I am using EclipseLink in my web application, and I am having a hard time gracefully catching and handling Exceptions it generates. I see from this thread what seems to be a similar problem, but I don't see how to work around or fix it. My code looks like this: public void persist(Category category) { try { utx.begin(); em.persist(category); utx.commit(); } catch (RollbackException ex) { // Log something } catch (HeuristicMixedException ex) { // Log something } catch

How to know what JAXB implementation is used?

跟風遠走 提交于 2020-01-01 04:34:08
问题 I am using MOXy as JAXB Implementation but somehow I would like to show the Implementation Name (e.g. Moxy) and the version number on some admin screen (dynamically). How can I retrieve that info from JAXB? Cheers 回答1: You could do something like the following to figure out the JAXB impl being used: import javax.xml.bind.JAXBContext; public class Demo { private static final String MOXY_JAXB_CONTEXT = "org.eclipse.persistence.jaxb.JAXBContext"; private static final String METRO_JAXB_CONTEXT =