openjpa

Using enum as id

◇◆丶佛笑我妖孽 提交于 2019-12-08 19:37:49
问题 Using JPA, can we define an enum as id of an entity? I've tried the following: public enum AssetType { .... } @Entity @IdClass(AssetType.class) public class Adkeys { private AssetType type; @Id @Enumerated(EnumType.STRING) @Column(nullable = false) public AssetType getType() { return type; } } Using OpenJPA, it complains: org.apache.openjpa.persistence.ArgumentException: The id class "class aa.AssetType" specified by type "class aa.Adkeys" does not have a public no-args constructor. So my

Error while updating data using Springboot data rest and OpenJPA

旧街凉风 提交于 2019-12-08 06:45:45
问题 I am working on Springboot data rest with OpenJPA application, but getting the below exception: RepositoryRestExceptionHandler : Cannot cast org.apache.openjpa.util.LongId to java.lang.Long java.lang.ClassCastException: Cannot cast org.apache.openjpa.util.LongId to java.lang.Long Below is the entity class: Station.java @Entity @Table(name = "STATION") public class Station extends GenericEntityModel<Long> { @Id @SequenceGenerator(name="STATION_SEQ_GEN", sequenceName="STATION_SEQ_GEN",

Does OpenJPA have any support for batch insert?

陌路散爱 提交于 2019-12-08 02:03:43
问题 Does OpenJPA have any support for batch insert similar to Hibernate? I haven't found it in the docs, but I'm hoping I missed it. I know JPA doesn't support it in general. 回答1: Short answer, yes. Longer answer, take the link to Hibernate documentation and replace the Session with a JPA EntityManager. EntityManager em = emf.createEntityManager(); Transaction tx = em.getTransaction(); tx.begin(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); em.persist(customer); if (

Primary Key (ID) not retrieved (?) from database using OpenJPA

好久不见. 提交于 2019-12-08 01:08:51
问题 This is a simple program to write to and read from a mysql database. When I enter the test data, all of it is visible in the mySQL client. Yet, when I use OpenJPA to retrieve the same data, all the ids appear "0", but the names are correct. What might be the cause for IDs to get lost during the transaction? POJO Class import java.io.Serializable; import javax.persistence.*; @Entity (name="People") public class People implements Serializable{ /** * */ private static final long serialVersionUID

how to make openjpa 2.2.0 not persist foreign key

不羁岁月 提交于 2019-12-07 12:19:50
问题 I have two tables.. Asset table ASSET_ID SYSIBM INTEGER 4 0 No USER_ID SYSIBM INTEGER 4 0 No ASSET_TYPE_ID SYSIBM SMALLINT 2 0 No ACCESSIBILITY_ID SYSIBM SMALLINT 2 0 Yes DOWNLOAD_TYPE_ID SYSIBM SMALLINT 2 0 No ASSET_STATUS_ID SYSIBM SMALLINT 2 0 No ASSET_MARKETING_ID SYSIBM SMALLINT 2 0 Yes ASSET_PI_SPI_ID SYSIBM SMALLINT 2 0 Yes and the Accesibility table ACCESSIBILITY_ID SYSIBM SMALLINT 2 0 No ACCESSIBILITY_DESC SYSIBM VARCHAR 50 0 No i have two beans, Asset Bean @Column(name="ASSET_ID")

How to do OpenJPA enhancement with Ant + IntelliJ IDEA

試著忘記壹切 提交于 2019-12-07 03:54:25
问题 This is driving me crazy and I'm shocked that official documentation is absolutely useles. Here is what I have: IntelliJ IDEA 11 OpenJPA 2.1.1 Since openjpa is added into list of used libraries I already had classpath to OpenJPA which looks like this <path id="library.openjpa.classpath"> <fileset dir="${basedir}/lib/openjpa"> <patternset refid="library.patterns"/> </fileset> </path> According to official documentation I added following target <target name="enhance"> <copy includeemptydirs=

selecting all rows from a database using JPA in WebSphere

不问归期 提交于 2019-12-06 19:02:51
问题 I am trying to implement a web service that uses open JPA to access the data layer. I am using websphere v7.0 and JPA 2.0. This service is going to get all rows out of a small db (about 6 rows and it won't expand much at all in the future). I am attempting to get all rows and return them through the user. I am right now creating the Session Bean that will retrieve the data. I have several JPA objects one of them (representing a row of all the data I want to return) looks like so... @Entity

InvalidStateException while trying to enter data into DB

风流意气都作罢 提交于 2019-12-06 15:53:37
I have a method that return the entity manager for particular DB.Now when i use the method for the first time to get entity manager everything works fine.I can save data into any tables A,B,C using entity manager.Now say i get a exception while saving in table B Now when I try to perform any operation on DB after geting exception above, the next time i try to run same code it fails when updating in table A itself.I can see folloing eception <openjpa-1.2.2-SNAPSHOT-r422266:778978M-OPENJPA-975 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException: The factory has been closed.

Is a method in a JPA entity allowed to throw an Exception?

耗尽温柔 提交于 2019-12-06 13:31:45
I have a problem with an @Entity I am trying to create. The problem arises when trying to test the class in Eclipse using an OpenJPA implementation (I have not tried others so not sure if it might work with them). My test case is simple enough in that it creates an EntityManagerFactory (which automatically finds the persistence.xml on my classpath) and then it tries to create an EntityManager from the factory. This is when I get hit with a very ambiguous 'PersistenceException: null' error. The Entity with the problem is the following LogError class. I have stripped it down to the bare minimum

Custom ClassLoader not garbage collected

谁说胖子不能爱 提交于 2019-12-06 13:28:00
问题 In an attempt to solve this problem, I built a (very) small project that is reproducing part of it. It is a NetBeans project using Glassfish v2.1.1 and OpenJpa-1.2.2. Globally, the goal is to be able to reload dynamically some business code (called 'tasks') without the need to (re)make a full deployment (eg via asadmin). In the project there are two of them: PersonTask and AddressTask which are simply accessing some data and printing them out. In order to do that, I've implemented a custom