eclipselink

Eclipselink with MongoDB java.lang.ClassCastException

折月煮酒 提交于 2019-12-02 04:20:57
I'm trying to configure a nosql persistence unit using Eclipselink and MongoDB but Im getting the following stack exception during deployment; ... SEVERE: java.lang.ClassCastException: org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform cannot be cast to org.eclipse.persistence.internal.databaseaccess.DatabasePlatform at org.eclipse.persistence.sequencing.TableSequence.onConnect(TableSequence.java:168) at org.eclipse.persistence.sequencing.Sequence.onConnect(Sequence.java:270) at org.eclipse.persistence.internal.sequencing.SequencingManager.onConnectSequences(SequencingManager.java:927)

JPA EntityManager.detach() still load lazy relations

女生的网名这么多〃 提交于 2019-12-02 04:20:11
问题 I got a problem that goes against my understanding of how it supposed to work. I have a Arquillian-test that tests a repository-method with a JPA query. The test persists an object, and then persists an another object with the first persisted object in a field. Then it calls the repository-method. Next the test detaches (and clear the entitymanager, checks that the object is not contained in the em etc etc). Last the test checks if the related object is there or not (it shouldn't since the

Can I get MOXy to rename an element when generating json?

北城余情 提交于 2019-12-02 03:56:57
From a common JAXB model the xml generated can be of the form <ipi-list><ipi>1001</ipi><ipi>1002</ipi></ipi-list> because in json we have arrays we dont need both elements, so by using MOXy's oxml extensions I can flatten the output to give "ipi" : [ "1001", "1002" ], but because ipi now refers to an array of things I would like it to be called ipis not ipi "ipis" : [ "1001", "1002" ], Is there a way to get MOXy to rename an element ? You could use EclipseLink JAXB (MOXy) 's external mapping document to tweak the mapping for either the XML or JSON representation. IPIList Below is a domain

EclipseLinke:No resource files named META-INF/services/javax.persistence.spi:No PersistenceProvider were found

南笙酒味 提交于 2019-12-02 02:18:39
问题 I am using EclipseLink and even I have all necessary jar files imported with maven, I get still the Exception: Exception in thread "main" javax.persistence.PersistenceException: No resource files named META-INF/services/javax.persistence.spi.PersistenceProvider were found. Please make sure that the persistence provider jar file is in your classpath. In Maven pom I have the dependency: <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0.2<

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

十年热恋 提交于 2019-12-02 02:17:40
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 and says that DocTypeA needs a primary key. How can I isolate the primary key and put it in the super

How to dynamically generate SQL query based on user’s selections?

大城市里の小女人 提交于 2019-12-02 02:06:07
问题 This is the same question as: How to dynamically generate SQL query based on user's selections? The only difference is, that I'm interested in seeing solutions also using Java/JPA (+possibly EclipseLink or Hibernate specific extensions). I need to create a GUI, using which users can select several attributes which will be used to query the database to find suitable persons. I'm looking for ideas how to dynamically generate the database query according to user's choices. Query will contain

Unknown entity bean class after hot deploy: netbeans 6.9 + glassfish 2.1 + eclipselink jpa 2.0

孤人 提交于 2019-12-02 01:28:53
问题 When I deploy my app, it works perfectly until I make a change, save, and netbeans hot deploys the application. At this point I get an unknown entity bean class error on a class that has the @entity and it's included in my persistence.xml. When this happens, anything dealing with jpa stops working. Only if I restart the server will my jpa stuff start working again. If I turn deploy on save off in my project and I only manually save and deploy I get the same results. Is this just a netbeans

Updated data (in Database) is not visible via JPA/Eclipselink

瘦欲@ 提交于 2019-12-02 01:28:37
问题 I have Oracle DB and Java project which is connected to the DB using JPA/Eclipselink. The problem is that when some data updated in the database (manually using Oracle SQL developer), this data is not visible via JPA, only old values. What can cause such problems? 回答1: Please try em.refresh() JPA's EntityManager will be unaware of any changes you made outside its transaction till it reloads the data. Above command will make it reload the data. If it is a List (populated using select), then

eclipselink merge() without initial SELECT

帅比萌擦擦* 提交于 2019-12-02 01:16:50
I am trying to perform a merge(entity) using eclipselink, and I would like to indicate to eclipse if that will be an update or insert, so it does not have to perform the initial select query. Thanks to the progress made in this question , I have the following: UnitOfWorkImpl uow = (UnitOfWorkImpl) ((EntityManagerImpl) em.getDelegate()).getUnitOfWork(); if (dbObj.isInDB()) { uow.updateObject(dbObj); } else { uow.insertObject(dbObj); } However, i get the following: org.eclipse.persistence.exceptions.QueryException: Exception Description: Objects cannot be written during a UnitOfWork, they must

How to dynamically generate SQL query based on user’s selections?

耗尽温柔 提交于 2019-12-02 00:48:21
This is the same question as: How to dynamically generate SQL query based on user's selections? The only difference is, that I'm interested in seeing solutions also using Java/JPA (+possibly EclipseLink or Hibernate specific extensions). I need to create a GUI, using which users can select several attributes which will be used to query the database to find suitable persons. I'm looking for ideas how to dynamically generate the database query according to user's choices. Query will contain several fields, but to get the idea I will include only three of those below as an example: Occupation -