Re: Able to remove relation with ManyToMany and no cascade.
Hi, > Access the student list and remove the entry in the list with SID "1" What exactly does 'remove' imply? Is it something like: a) team.getStudents().remove(1); or b) em.remove(team.getStudents().get(1)); If it is (a) then no database change is expected. Removal of entity X from a Java collection will not, in general, imply deletion of X from database. This is in agreement with association relation that collection membership implies. However, OpenJPA does provide @Dependent/@ElementDependent annotations to mean ownership of B by A. Annotating uni-cardinality or multi-cardinality relation with @Dependent or @ElementDependent will cause deletion from database when the relationship is severed/nullified in memory. In JPA 2.0, this behavior is being specified under @OrphanRemoval annotation or an equivalent cascade type. If it is (b) then the record should be deleted from database. Jitendra chintamadaka wrote: > > Ok, section 3.2.3 in JSR 220, does explain. > > Assuming that cascade attribute does not have any effect (as its not > mentioned in that section). This then is an issue with the JPA > specification itself. As introducing unwanted DB changes cannot be > prevented with a annotation. May be I should open a issue or > recommendation for JPA Specification itself. > > Regards > > > - Original Message > From: Pinaki Poddar <[EMAIL PROTECTED]> > To: users@openjpa.apache.org > Sent: Monday, July 7, 2008 8:04:03 PM > Subject: Re: Able to remove relation with ManyToMany and no cascade. > > > Hi, > >> I have looked up the JSR 220 and did not find any specific mention on >> this >> scenario. This seems like a >> bug in the implementation. Please let me know if this really is a bug, so >> I can submit a bug report. > > JSR-220 Section 3.2.3 "Synchronization to the Database" pp 44 says: > "Bidirectional relationships between managed entities will be persisted > based on references held by the owning side of the relationship" > > The scenario you have described can be explained and not attributed as a > limitation of implementation by the above. > > > -- > View this message in context: > http://n2.nabble.com/Able-to-remove-relation-with-ManyToMany-and-no-cascade.-tp221593p363223.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > > > > -- View this message in context: http://n2.nabble.com/Able-to-remove-relation-with-ManyToMany-and-no-cascade.-tp221593p471622.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: How to find cause for PersistenceException?
Hi, Was looking for the stack trace to see the context so that we can locate an appropriate code region to generate a more informative error message. -- View this message in context: http://n2.nabble.com/How-to-find-cause-for-PersistenceException--tp221194p471571.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Clustering & ID TableGenerator (OPENJPA_SEQUENCE_TABLE)
Are you referring to clustering of databases or clustering of JVM/AppServers? If it is the former, openjpa-slice module that let a persistent unit be connected to multiple databases in the same transaction may be of some relevance. In slice, we designate one database in the cluster as 'master' for the purpose of ID generation. Michael Vorburger-4 wrote: > > Hello, > > How do you do Clustering and ID TableGenerator > (e.g.OPENJPA_SEQUENCE_TABLE) ? > > Will this somehow magically work (how?), or will different nodes "step > on each other's feet" because they'll use the same PK? Can they each use > different "slices" ? > > If impossible, do you HAVE to use Identify columns or Sequence > generators in the DB? I thought that was not such a good idea (if you > have a choice), performance wise, because it requires an extra > round-trip to the DB to get the PK e.g. to set it as FK. Also > https://issues.apache.org/jira/browse/OPENJPA-464 states that Statement > Batching won't work with GeneratedType=IDENTITY - so this option doesn't > seem terribly tempting in order to get ID and clustering happily married > together. > > How do people out there do this with OpenJPA? > > Thank you, > Michael > > _ > Michael Vorburger, Odyssey Financial Technologies > > > > > This email and any files transmitted with it are CONFIDENTIAL and > intended > solely for the use of the individual or entity to which they are > addressed. > Any unauthorized copying, disclosure, or distribution of the material > within > this email is strictly forbidden. > Any views or opinions presented within this e-mail are solely those of > the > author and do not necessarily represent those of Odyssey Financial > Technologies SA unless otherwise specifically stated. > An electronic message is not binding on its sender. Any message > referring to > a binding engagement must be confirmed in writing and duly signed. > If you have received this email in error, please notify the sender > immediately > and delete the original. > -- View this message in context: http://n2.nabble.com/Clustering---ID-TableGenerator-%28OPENJPA_SEQUENCE_TABLE%29-tp471147p471566.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Does ConnectionRetainMode do anything?
Hi, > connection being thrown away after I finish a transaction and close the > EntityManager. ConnectionRetainMode 'always' retains the connection *until* the EntityManager closes. Once you close the EntityManager, the connection will return to the pool for obvious reasons. The following test passes on ConnectionRetainMode='always' public void testRetain() { EntityManager em = getEM(); em.getTransaction().begin(); em.persist(new PObject()); Object con = OpenJPAPersistence.cast(em).getConnection(); em.getTransaction().commit(); for (int i=0; i<10; i++) { em.getTransaction().begin(); em.persist(new PObject()); Object con2 = OpenJPAPersistence.cast(em).getConnection(); assertEquals(con, con2); em.getTransaction().commit(); } } -- View this message in context: http://n2.nabble.com/Does-ConnectionRetainMode-do-anything--tp471015p471550.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: EAGER vs. LAZY loading - weird behaviour in OpenJPA 1.0.1
Hi, You are experiencing the problem described in JIRA issue OPENJPA-241 (this issue is still OPEN). Catalina On Tue, Jul 8, 2008 at 5:41 AM, Beniamin Mazan <[EMAIL PROTECTED]> wrote: > > > > Ignacio Andreu wrote: > > > > As far as I know, if you use the eager strategy is normal that OpenJPA > > generates queries to load the diferent relations from the database. If > you > > > > You're right of course. But OpenJPA generate queries to load object that > are > already loaded. For example if loading Product causes loading RequestLog I > expected that OpenJPA has no need to query for Product which is owner of > RequestLog and is loaded to Context. Especially when I use bi-directional > relation. > Am I wrong ? > > > - > thanks, Beniamin > My homesite - http://www.mazan.pl http://www.mazan.pl > -- > View this message in context: > http://n2.nabble.com/EAGER-vs.-LAZY-loading---weird-behaviour-in-OpenJPA-1.0.1-tp364201p364227.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > >
Re: How to find cause for PersistenceException?
Hi, Pinaki. Even the full stack trace had no reference to the field that was accessed at that time. Unfortunately right now I do not see how to reproduce that stack trace. The cause is that I played around with many things and finally let Netbeans generate my entities again, seeing that all CHAR(1) columns now map to String. Thank you for your interest. If the problem shows up again I will come back and post a full stack trace. Hiran - Original Message - From: "Pinaki Poddar" <[EMAIL PROTECTED]> To: Sent: Monday, July 07, 2008 3:50 PM Subject: Re: How to find cause for PersistenceException? Please post the entire stack trace. PersistenceException often nests the root cause of the error and your application needs to recurse through those nested exception to pick the root cause. In this case, the context where the error has been detected is likely to be too narrow to provide enough information (whereas in most cases, OpenJPA exception provides adequate contextual information) -- but having the entire stack trace will help. Hiran Chaudhuri wrote: Hi there. On classes generated from a database with Netbeans 6.1 I get such an exception at runtime: org.apache.openjpa.persistence.PersistenceException: Invalid value for getInt() - 'N' Now I can imagine that int is a wrong mapping for the regarding table column and I know which table is accessed - but how do I find out which column this message relates to? Hiran Chaudhuri ___ Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 30 Tage kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=00 -- View this message in context: http://n2.nabble.com/How-to-find-cause-for-PersistenceException--tp221194p363179.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Persist method is updating my reference tables, too.
I am using an EntityManager to look up information in a reference table. I use the resulting object to set an int value in a new record I will persist. When I persist, the new record is inserted, and the reference table is updated (yikes). Am I not understanding something about this? Should I set up a second EntityManager for "read-only" database records? Eric -- View this message in context: http://n2.nabble.com/Persist-method-is-updating-my-reference-tables%2C-too.-tp471292p471292.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Using QueryResultCache to store reference tables?
I have some queries on reference tables that won't be changing often. Can I use QueryResultCache to store those queries/results? I don't understand the documentation on this.:confused: Eric -- View this message in context: http://n2.nabble.com/Using-QueryResultCache-to-store-reference-tables--tp471290p471290.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Clustering & ID TableGenerator (OPENJPA_SEQUENCE_TABLE)
Hello, How do you do Clustering and ID TableGenerator (e.g.OPENJPA_SEQUENCE_TABLE) ? Will this somehow magically work (how?), or will different nodes "step on each other's feet" because they'll use the same PK? Can they each use different "slices" ? If impossible, do you HAVE to use Identify columns or Sequence generators in the DB? I thought that was not such a good idea (if you have a choice), performance wise, because it requires an extra round-trip to the DB to get the PK e.g. to set it as FK. Also https://issues.apache.org/jira/browse/OPENJPA-464 states that Statement Batching won't work with GeneratedType=IDENTITY - so this option doesn't seem terribly tempting in order to get ID and clustering happily married together. How do people out there do this with OpenJPA? Thank you, Michael _ Michael Vorburger, Odyssey Financial Technologies This email and any files transmitted with it are CONFIDENTIAL and intended solely for the use of the individual or entity to which they are addressed. Any unauthorized copying, disclosure, or distribution of the material within this email is strictly forbidden. Any views or opinions presented within this e-mail are solely those of the author and do not necessarily represent those of Odyssey Financial Technologies SA unless otherwise specifically stated. An electronic message is not binding on its sender. Any message referring to a binding engagement must be confirmed in writing and duly signed. If you have received this email in error, please notify the sender immediately and delete the original.
Stored Procedure support (AKA replace INSERT and UPDATE)
Hello, Does OpenJPA support Stored Procedures, like other ORMs (TopLink/EclipseLink, Hibernate)? Imagine a DB that exposes Views for SELECT-ing, and that requires you to call a stored proc for most INSERTs or UPDATEs. Is there any way to configure (?) something like "When you persist the X Entity, don't do an INSERT ... INTO X, but CALL ... something" ? Dito for UPDATE. I realize you can use (named) native queries that do Stored Procedures for queries, but that's not "transparent" in any way and I don't see how that could be used to replace INSERT/UPDATE after a persist(), unless I'm missing something. Reading e.g. https://issues.apache.org/jira/browse/OPENJPA-236 makes me think that it may be possible to "code" this somehow? Are any OpenJPA users doing this? Is this a good/bad idea? Is there anything coming / changing with the JPA 2.0 Spec in this space? Thank you, Michael _ Michael Vorburger, Odyssey Financial Technologies This email and any files transmitted with it are CONFIDENTIAL and intended solely for the use of the individual or entity to which they are addressed. Any unauthorized copying, disclosure, or distribution of the material within this email is strictly forbidden. Any views or opinions presented within this e-mail are solely those of the author and do not necessarily represent those of Odyssey Financial Technologies SA unless otherwise specifically stated. An electronic message is not binding on its sender. Any message referring to a binding engagement must be confirmed in writing and duly signed. If you have received this email in error, please notify the sender immediately and delete the original.
RE: Tomcat Injection
Hello, You may want to have a look at Spring's JPA support, which I believe enables you to do what you want (inject an EntityManager), even if Tomcat is not an EJB container. I found this http://java.sys-con.com/read/366275.htm article useful. This http://dev2dev.bea.com/pub/a/2006/03/jpa-spring-medrec.html looks useful too (haven't read it). I'm sure http://static.springframework.org/spring/docs/2.5.x/reference/orm.html#o rm-jpa says it all. Regards, Michael -Original Message- From: ericp56 [mailto:[EMAIL PROTECTED] Sent: mercredi, 9. juillet 2008 14:51 To: users@openjpa.apache.org Subject: Re: Tomcat Injection Indeed, that is the answer. For now, I need to stick with Tomcat, so I'll create an EntityManagerFactory singleton. Thanks! Eric -- View this message in context: http://n2.nabble.com/Tomcat-Injection-tp395699p469860.html Sent from the OpenJPA Users mailing list archive at Nabble.com. This email and any files transmitted with it are CONFIDENTIAL and intended solely for the use of the individual or entity to which they are addressed. Any unauthorized copying, disclosure, or distribution of the material within this email is strictly forbidden. Any views or opinions presented within this e-mail are solely those of the author and do not necessarily represent those of Odyssey Financial Technologies SA unless otherwise specifically stated. An electronic message is not binding on its sender. Any message referring to a binding engagement must be confirmed in writing and duly signed. If you have received this email in error, please notify the sender immediately and delete the original.
Re: Error while merging object three
Hi Ekin. I ran into a similar issue last week while using the merge operation. I found that since I had a bi-directional relationship with unmanaged entities (B <---> C in your case), OpenJPA needed both PERSIST and MERGE cascade enabled in order to maintain both sides of the relationship. That way, new related entities can be persisted and existing entities can be merged from either side of the relationship. This behavior does not appear to be specifically defined by section 3.2.4.1 of the JPA spec, but it is also in my opinion, not contradictory to the requirements which are defined. I could be totally off, but I was able to twist my own arm hard enough to convince myself that OpenJPA is working as expected. :-) Besides adding adding the cascade options to C, if you make the B ---> C relationship uni-directional or merge B (making it managed) before relating it to C (and vice-versa), the test also worked for me without problems. -Jeremy
Does ConnectionRetainMode do anything?
I may be missing something obvious, but I cannot get OpenJPA to hold onto a database connection. This is with 1.0.2 and 1.1.0 in a standalone unenhanced Swing client, no connection pooling. I've watched MySQL Administrator and netstat, but all I see is the connection being thrown away after I finish a transaction and close the EntityManager. Here's my persistence-unit: 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";> org.apache.openjpa.persistence.PersistenceProviderImpl com.xx.models.User Thanks, David
Re: Query problem with open jpa 1.0.2
It works. Thank you Fay. It seems I made a crappy error. Fay Wang wrote: > > Hi, >Please do the following: > > select j from job j > > > -fay > > --- On Tue, 7/8/08, tao <[EMAIL PROTECTED]> wrote: > >> From: tao <[EMAIL PROTECTED]> >> Subject: Query problem with open jpa 1.0.2 >> To: users@openjpa.apache.org >> Date: Tuesday, July 8, 2008, 3:30 PM >> Hi, I'm working on a project using openjpa 1.0.2. I got >> org.apache.openjpa.persistence.ArgumentException while >> executing a simple >> query today, wish someone can help me on this issue. Thanks >> >> The query I'm trying to execute is: >> "select job from job j" >> Moreover there is no problem for me to create a new job >> record. >> >> Three related persistence classes are defined as the >> following: >> >> @Table(name = "job") >> @Entity(name = "job") >> public class Job implements Serializable{ >> @Id >> @Column (name = "job_id") >> @GeneratedValue(strategy = GenerationType.IDENTITY) >> private long jobId; >> >> @Column (name = "job_name", length = 255, >> nullable = false) >> private String jobName; >> >> @Column >> private String status; >> >> @ManyToOne (optional = false) >> @JoinColumn(name = "create_by", >> referencedColumnName = "user_id") >> private User createUser; >> >> @Column (name = "create_time") >> private Date createTime; >> >> @ManyToOne (optional = true) >> @JoinColumn(name = "update_by", >> referencedColumnName = "user_id") >> private User updateUser; >> >> @Column (name = "update_time") >> private Date updateTime; >> >> @ManyToOne (optional = false, fetch = FetchType.EAGER) >> @JoinColumn(name = "proj_lead_id", >> referencedColumnName = "user_id") >> private User projectLead; >> >> @ManyToOne (optional = false, fetch = FetchType.EAGER) >> @JoinColumn(name = "designer_id", >> referencedColumnName = "user_id") >> private User designer; >> >> @Column (name = "approve_by") >> private String approveBy; >> >> @Column (name = "concept_date") >> private Date conceptDate; >> >> @Column (name = "vendor_due_date") >> private Date vendorDueDate; >> >> @Column (name = "release_date") >> private Date releaseDate; >> ... >> } >> >> @Entity(name = "user") >> @Table(name = "usr_user") >> public class User implements Serializable { >> >> private static final long serialVersionUID = 3L; >> >> @Id >> @Column (name = "user_id") >> @GeneratedValue(strategy = GenerationType.IDENTITY) >> private long userId; >> >> @Column >> private String password; >> >> @Column (name = "user_name", length = 20, >> nullable = false) >> private String userName; >> >> @Column (name = "first_name", length = 32, >> nullable = false) >> private String firstName; >> >> @Column (name = "last_name", length = 32, >> nullable = false) >> private String lastName; >> >> @Column (name = "mid_name", length = 20, >> nullable = true) >> private String midName; >> >> @ManyToOne (optional = false, fetch = >> FetchType.EAGER) >> @JoinColumn(name = "role_id", >> referencedColumnName = "role_id") >> private Role role; >> >> ... >> } >> >> @Entity (name = "role") >> @Table(name = "role") >> public class Role { >> @Id >> @Column (name="role_id") >> @GeneratedValue(strategy = GenerationType.IDENTITY) >> private long roleId; >> >> @Column (name="role_name", length = 20, nullable >> = false) >> private String roleName; >>... >> } >> >> and the exception details I got are >> javax.faces.FacesException: Error calling action method of >> component with id >> job-search-form:search-button >> at >> org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:69) >> at >> javax.faces.component.UICommand.broadcast(UICommand.java:121) >> at >> javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:292) >> at >> javax.faces.component.UIViewRoot.process(UIViewRoot.java:209) >> at >> javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:117) >> at >> org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32) >> at >> org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:103) >> at >> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76) >> at >> javax.faces.webapp.FacesServlet.service(FacesServlet.java:148) >> at >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >> at >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> at >> org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter
Re: Tomcat Injection
Indeed, that is the answer. For now, I need to stick with Tomcat, so I'll create an EntityManagerFactory singleton. Thanks! Eric -- View this message in context: http://n2.nabble.com/Tomcat-Injection-tp395699p469860.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Tomcat Injection
... on second thought: Does Tomcat do dependency injection at all? In my eyes it is a servlet container, not an application server. You might want to change to Glassfish, Geronimo or JBoss. But maybe such behaviour has been introduced to Tomcat and noone ever informed me about it... ;-) Hiran Chaudhuri > -Ursprüngliche Nachricht- > Von: "ericp56" <[EMAIL PROTECTED]> > Gesendet: 08.07.08 22:03:01 > An: users@openjpa.apache.org > Betreff: Tomcat Injection > > Hello, > > After reading some documentation, I though I had my injection code worked > out, but apparently not. > > I am using Tomcat with OpenJPA. > > In my class, I have: > @PersistenceUnit(unitName = "CallScheduler") > private @Resource(name="bean/OpenJPAEMF")OpenJPAEntityManagerFactory > emf; > In my META-INF/context.xml, I have: > factory="org.apache.openjpa.persistence.OpenJPAEntityManagerFactory" > type="org.apache.openjpa.persistence.OpenJPAEntityManagerFactory.class" > /> > > While executing a method in my class, emf is still null. > > How should I instantiate emf? I am under the impression that > OpenJPAPersistence.createEntityManagerFactory is for unmanaged code... > > Eric > -- > View this message in context: > http://n2.nabble.com/Tomcat-Injection-tp395699p395699.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > > ___ EINE FÜR ALLE: die kostenlose WEB.DE-Plattform für Freunde und Deine Homepage mit eigenem Namen. Jetzt starten! http://unddu.de/[EMAIL PROTECTED]
Re: Tomcat Injection
Try this: http://java.sun.com/javaee/5/docs/api/javax/persistence/Persistence.html For me it worked as soon as OpenJPA was able to find persistence.xml via the classpath. Alternatively you can provide the whole configuration via the map. Hiran Chaudhuri > -Ursprüngliche Nachricht- > Von: "ericp56" <[EMAIL PROTECTED]> > Gesendet: 08.07.08 22:40:06 > An: users@openjpa.apache.org > Betreff: Re: Tomcat Injection > > I tried: > emf = OpenJPAPersistence.getEntityManagerFactory(); > > but it doesn't find persistence.xml, and raises: > > org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or > DataSource class name > must be specified in the ConnectionDriverName property. > > Are there any samples out there? The ones included with OpenJPA don't > include any managed resources. > > > -- > View this message in context: > http://n2.nabble.com/Tomcat-Injection-tp395699p395729.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > > Ihre Messenger, Communities und E-Mails jetzt in einem Programm! WEB.DE MultiMessenger http://www.produkte.web.de/messenger/?did=3071