eclipselink

Why does EntityManager insert instead of updating?

不想你离开。 提交于 2019-12-04 02:54:16
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.getTransaction().commit(); em.close(); I confirm the primary key ID of the object by printing it before

How do I configure dynamic weaving using EclipseLink & Spring?

◇◆丶佛笑我妖孽 提交于 2019-12-04 02:21:18
How do I configure dynamic weaving using EclipseLink & Spring? Right now I'm trying to get this working with a Junit test, but I'll later have to have it work with Tomcat (my department has been standardized on it for something like 10 years). I'm running into two main problems: 1. Spring wants a load time weaver: Exception: java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:181) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies

How do I catch the constraint violation exception from EclipseLink?

白昼怎懂夜的黑 提交于 2019-12-04 00:59:13
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 (HeuristicRollbackException ex) { // Log something } catch (SecurityException ex) { // Log something } catch

EclipseLink native query result into POJO - Missing descriptor for [Class]

谁都会走 提交于 2019-12-03 23:31:50
I'm using EclipseLink to run some Native SQL. I need to return the data into a POJO. I followed the instructions at EclipseLink Docs , but I receive the error Missing descriptor for [Class] The query columns have been named to match the member variables of the POJO. Do I need to do some additional mapping? POJO: public class AnnouncementRecipientsFlattenedDTO { private BigDecimal announcementId; private String recipientAddress; private String type; public AnnouncementRecipientsFlattenedDTO() { super(); } public AnnouncementRecipientsFlattenedDTO(BigDecimal announcementId, String

Exception in thread “main” javax.xml.bind.PropertyException: name: eclipselink.media-type value: application/json

匆匆过客 提交于 2019-12-03 22:38:27
I'm attempting to follow the example located here but get an javax.xml.bind.PropertyException. I receive this exception because of the following line of code: marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, "application/json"); I have literally copy/pasted the example listed above so my code is exactly what you see there. Searching SO and Google for this has not been helpful, and thought I'd bring this to the geniuses at SO for some help. Any help would be most appreciated, (de)serialization with JSON and XML with json.org, Jackson, and JAXB has turned into a black and bottomless pit

Getting a JDBC connection from EclipseLink

笑着哭i 提交于 2019-12-03 20:41:17
问题 using EclipseLink as JPA 2.0 provider, I can obtain a JDBC connection by simply calling Connection con = entityManager.unwrap(Connection.class); But I'm unsure what I'm responsible for. Do I have to close the connection after submitting my queries? Or are I'm not allowed to close the connection, because EclipseLink also uses this connection internally. Or does it not care, because EclipseLink observes my behaviour and closes the connection automatically if I don't do it? 回答1: If you are in

GAE CloudSQL with MySQL access denied

半腔热情 提交于 2019-12-03 20:18:38
I have a web application that is working fine under the following environment GWT 2.4.0 RestEasy 2.3.2.Final JAX-RS & JAXB Hibernate JPA 2.0 (hibernate-entitymanager + hibernate-validator) 4.2.0.Final MySQL 5.5.22 at localhost (Ubuntu 12.04) VMware 2.6 tomcat server The application is working successfully using JAX-RS, JAXB, Jackson JSON provider, Hibernate JPA annotations all mixed together into the same DTO. I am trying to port it to GAE CloudSQL. I am encountering MySQL access errors. I had to change the ORM from Hibernate to EclipseLink 2.3.2. Reminder : I respectfully request answerers

Mapping Oracle XMLType on JPA (EclipseLink)

孤者浪人 提交于 2019-12-03 20:16:17
问题 We have a project with some special requirements, one of wich is getting data from a XMLType database column from an Oracle 10g database. We have found an easy solution using JDBC, but it would drive the application a little messy, as all the data access is being done through JPA (the implementation used is EclipseLink). We have done some research, and have found some solutions, as using Converters and other auxiliar types, but the implementations seemed a little complicated. So, my question

JPQL query with WHERE on nested fields

◇◆丶佛笑我妖孽 提交于 2019-12-03 19:59:28
问题 I have a java entity class UserBean with a list of events: @OneToMany private List<EventBean> events; EventBean has Date variable: @Temporal(javax.persistence.TemporalType.TIMESTAMP) private Date eventDate; Now in UserBean I want to create a NamedQuery that returns all dates that fall within a specific range: @NamedQuery(name="User.findEventsWithinDates", query="SELECT u.events FROM UserBean u WHERE u.name = :name AND u.events.eventDate > :startDate AND u.events.eventDate < :endDate") The

Avoiding N+One selects and Invalid results from eclipselink with batch read

坚强是说给别人听的谎言 提交于 2019-12-03 19:34:07
问题 I'm trying to cut down the number of n+1 selects incurred by my application, the application uses EclipseLink as an ORM and in as many places as possible I've tried to add the batch read hint to queries. In a large number of places in the app I don't always know exactly what relationships I'll be traversing (My view displays fields based on user preferences). At that point I'd like to run one query to populate all of those relationships for my objects. My dream is to call something like