openjpa

Why Entitys uninitialized collection is initialized automatically only for Entities persisted before current transaction?

醉酒当歌 提交于 2019-12-25 08:53:50
问题 (Please feel free to edit the title after reading this question) I have quite simple @ManyToOne bidirectional mapping between entities Parent and Child . The list of children Collection<Child> children in Parent is never initialized so it should be null . When using EntityManager.find(...) for previously persisted Parent and then getting the list from that Parent gives ArrayList even there are no children yet with this Parent and it is fine. However if persisting or merging a new Parent in

OpenJPA Webspere 7 Log4j configuration

故事扮演 提交于 2019-12-25 05:23:27
问题 Guys I’m struggling with this one. I am trying to redirect logging from systemout. to a log4j rollingappender file with no success, below is a sample of my persistent.xml <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="R_TEST"

Getting column index out of range, 0 < 1

橙三吉。 提交于 2019-12-25 05:23:14
问题 I am using OpenJPA 2.2.0 and when I am executing a select statement I am getting "Column index out of range, 0 < 1" error. EntityManager entityMgrObj = emf.getEntityManager(); entityMgrObj.clear(); Query query = entityMgrObj.createNativeQuery("select * from company_user where user_id = 1001); List<CompanyUserDO> companyUserDOObj = null; try { companyUserDOObj = query.getResultList(); } catch (Exception e) { System.out.println(e.getMessage()); } When the query.getResultList() executes I get

jpa namedquery with literals changed to prepared statement

大城市里の小女人 提交于 2019-12-24 13:15:15
问题 I have a jpa (openjpa-2.2.1) namedquery that has some hardcoded literals (ex: a.status <> 'X') - the problem is at runtime the generated query is actually a prepared statement (a.status <> ?) Is there a way to force JPA run the query as is? (i would like to keep it as namedquery, not implement it as native query or other ways) I would like to run the query as is because of performance reasons - the static query runs in a db client in about 2 seconds while the prepared statement fired from

How to mix inheritance type in JPA

这一生的挚爱 提交于 2019-12-23 01:11:38
问题 How to mix single table type inheritance with join table type in the same inheritance tree? I'm not using hibernate just JPA. I know there is no official support for mixed inheritance by reading the JPA spec. I can't change the architecture. It did worked with hibernate but now I need to implement this using openjpa. I'm looking for some workaround. 回答1: this is working for me: Superclass: @Entity @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "TYPE

InvalidStateException while trying to enter data into DB

限于喜欢 提交于 2019-12-22 11:37:33
问题 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

OpenJPA 2.1.1 enhancement problem on Glassfish 3.1.1

那年仲夏 提交于 2019-12-22 10:16:39
问题 My problem is this exception: Caused by: <openjpa-2.1.1-r422266:1148538 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: " I'm trying to get an very simple java application with jsf and jpa running, but there seems to be a problem with the enhancement of my entities. As far as I know, tries OpenJPA to enhance my

How to use OpenJPA 2.2 on WebSphere 7.0?

不想你离开。 提交于 2019-12-22 08:20:07
问题 I'm starting a project where I need to use OpenJPA 2.2 and run on WAS 7.0. How do I make WAS 7.0 pick up the OpenJPA 2.2 jar instead of using its own? 回答1: You may configure OpenJPA 2.2 as outlined in WAS7 infocenter at Using third-party persistence providers article. It is stated in this article that in addition to using JPA providers from other vendors, "Applications can also specify an Apache OpenJPA provider that is other than the version that is included with the application server." 来源:

Fetching & Updating lazy-loaded many-many fields in Spring Data REST

杀马特。学长 韩版系。学妹 提交于 2019-12-22 05:20:22
问题 How do I correctly expose lazy-loaded many-many fields so that users can GET / PATCH / POST / DELETE many-many entity relationships in Spring Data REST? For example, given a Student entity and Teacher entity bound by a many to many relationship, with the following POJOs: @Entity public class Teacher { // owner of bidirectional relationship @Id private int id; private String name; @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "teacher_student", joinColumns = @JoinColumn(name = "teacher

Maven archetypes for OpenJPA

元气小坏坏 提交于 2019-12-21 21:57:47
问题 Greetings. I'm just starting to explore Maven and I use m2eclipse as to use Maven in Eclipse. I found that there is a hibernate-based archetype with Group Id: com.rfc.maven.archetypes and Artifact Id: jpa-maven-archetype Does anybody knows if there are archetypes for OpenJPA-based projected with test frameworks included? Thanks a lot. 回答1: Does anybody knows if there are archetypes for OpenJPA-based projected with test frameworks included? Not to my knowledge. So my suggestion would be to use