Re: Unexpected behavior with foreign key constraints

2007-11-14 Thread Christian Defoy
It could be because OpenJPA does not know about your foreign keys... You have to tell OpenJPA that there is a foreign key using the @ForeignKey annotation or instruct OpenJPA to detect the foreign keys by inspecting your schema. To do this, you have to specify the following property in your persis

Re: Named query containing @Enumerated comparison

2007-11-13 Thread Christian Defoy
I always use something of the form "SELECT i FROM Item WHERE i.status = :value" query.setParameter( "value", ItemStatus.New.ordinal() ); since my enums are materialized as integers in the DB. It is related to the @Enumerated annotation. Using that annotation, you can specify that your e

Re: Removing an entity with a new merged object?

2007-10-29 Thread Christian Defoy
Hi, Instead of creating a new Department with the ID of the department that you want to delete, you should use the getReference() method as such: Department toRemove = em.getReference( Department.class, "1234" ); em.getTransaction().begin(); em.remove( toRemove ); em.getTransaction().commit(); H

Re: Unique constraint on column not being enforced?

2007-10-11 Thread Christian Defoy
If I recall correctly, the manual says that the @UniqueConstraint is used to create proper database constraints when OpenJPA creates your database. Unicity is enforced by database constraints, not by OpenJPA. Christian On 10/11/07, Derry Cannon <[EMAIL PROTECTED]> wrote: > Hey, there! > > I've g

Re: Exception in thread "main" java.lang.StackOverflowError

2007-10-09 Thread Christian Defoy
Hello, I ran your test class and it worked fine. Since there is no linkage between the 1000 instances you are creating, I see no reason for a stack overflow. I even added some code to link a tabela to its pai (father, if babel fish is right). That still does not produce a stack overflow... Are

Re: class org.apache.openjpa.util.java$util$Collections$SingletonSet$0$proxy cannot access its superclass java.util.Collections$SingletonSet

2007-09-27 Thread Christian Defoy
A to > at least avoid the error somehow, which should be sufficient since > SingletonSet is just an optimization. > > -Patrick > > On 9/25/07, Christian Defoy <[EMAIL PROTECTED]> wrote: > > Hello! > > > > I am getting a strange message when merging an entity.

class org.apache.openjpa.util.java$util$Collections$SingletonSet$0$proxy cannot access its superclass java.util.Collections$SingletonSet

2007-09-25 Thread Christian Defoy
Hello! I am getting a strange message when merging an entity. My entity contains a set of objects of class A. Each of these objects, in turn, have an attribute that is a set. My entity gets detached, then a bunch of As get added and every A contains a set. Most of the As will contain a singlet

Re: Why is Derby Jar in OpenJPA distribution?

2007-09-14 Thread Christian Defoy
it for convenience for the binary download so that people can get > started easily. > > -Patrick > > On 9/14/07, Christian Defoy <[EMAIL PROTECTED]> wrote: > > Hello! > > > > Do I need to distribute the Derby jar with my application because it > > is part

Why is Derby Jar in OpenJPA distribution?

2007-09-14 Thread Christian Defoy
Hello! Do I need to distribute the Derby jar with my application because it is part of the OpenJPA 0.9.7 distribution? Included in the distribution is derby-10.2.2.0.jar. I did not include it in the classpath for testing and I have seen no problem so far. Is one lurking in the shadows? Am I as

Re: Enhancer Ant Task in Netbeans?

2007-09-12 Thread Christian Defoy
It is a reference to a path defined somewhere else in the build.xml file. It is typically used when a classpath or a path has to be used in several places in the file. You can find the doc for this at http://ant.apache.org/manual/index.html Click on the Concept and Types link and then click on

Re: Cascade persist

2007-09-10 Thread Christian Defoy
As far as I know, you have to tell OpenJPA of the existence of the foreign keys. You can do that by using the @ForeignKey annotation. Alternatively, you can add this property to your persistence.xml. It will tell OpenJPA to discover what it can about foreign keys: There is also a problem that

Re: Ant enhancement

2007-09-08 Thread Christian Defoy
persistent classes list, or all metadata files in classpath directories if you have not listed your persistent classes. Use -help to display tool usage information. Is there a verbose mode that I could use to make sure the proper classes are enhanced? Thanks! Christian On 9/8/07, Christian Defoy

Ant enhancement

2007-09-08 Thread Christian Defoy
Hello! I am enhancing my classes at build time and that works fine as far as I know. My class files get a new timestamp so I guess they are enhanced. However, when I launch my app, I get Could not locate metadata for the class using alias "Shape". Registered alias mappings: "{Shape=null}" Do I

Invalid SQL generated

2007-09-07 Thread Christian Defoy
Hi, I get an invalid SQL statement when I do the following: 1- create a new instance of C 2- create a new instance of A 3- put a link from C to A 4- load a persistent instance of B 5- detach B 6- put a link from B to A 7- put a link from A to B 8- persist C When I commit my transaction, I get an

Re: Join table with extra value

2007-09-06 Thread Christian Defoy
take that approach. You'd just set up a pair of > one-to-many relations from A to A_B and B to A_B; you wouldn't need to > do anything special to make it work. > > -Patrick > > On 9/6/07, Christian Defoy <[EMAIL PROTECTED]> wrote: > > Hello, > > >

Join table with extra value

2007-09-06 Thread Christian Defoy
Hello, I have two objects, A and B, that are involved in a many to many relationship. That portion works ok if class A contains: @ManyToMany( fetch=FetchType.EAGER, cascade=CascadeType.ALL ) @JoinTable( name="a_b", [EMAIL PROTECTED]( name="a_id", referencedColumnName="a_id" ),

Re: Id column = null?

2007-09-06 Thread Christian Defoy
Hi, It is probably because you do not have a setId() method in your WebPage class. Since you are using Property access, you must define setters for every field (or at least that's how I understand it). If you were using Field access, you wouldn't have that issue. Hope this helps! Christian On

Re: Skip a computed field on insert and update

2007-08-30 Thread Christian Defoy
gt; > private Shape shape; > > @Column( name="shape_id", insertable=false, updatable=false ) > > That will tell OpenJPA to not insert or update those columns. > > -Patrick > > On 8/30/07, Christian Defoy <[EMAIL PROTECTED]> wrote: > > Hello, > &

Skip a computed field on insert and update

2007-08-30 Thread Christian Defoy
Hello, I have a Shape object that is referred to by an Attachment object. The ID for Attachment is computed based on the ID of the related Shape and the database enforces that by having the Attachment.shape_id field as a computed field. create table Shape ( shape_id int identity not null prim

Re: Connection usage

2007-08-23 Thread Christian Defoy
classes anyways, it should be able to do more-eager loading. > > It would be interesting to know if things get resolved by putting an > emf.createEntityManager().close() call somewhere before you do any > real work in the application. > > -Patrick > > On 8/23/07, Christian D

Re: Connection usage

2007-08-23 Thread Christian Defoy
ing. > > -Patrick > > On 8/23/07, Christian Defoy <[EMAIL PROTECTED]> wrote: > > Hi Patrick, > > > > Here is the stack trace of the second call to getConnection(): > > > > java.lang.Exception: Stack trace > > at java.lang.Thread.dumpStack

Re: Connection usage

2007-08-23 Thread Christian Defoy
ends ShapeCommand { .. } Christian On 8/23/07, Patrick Linskey <[EMAIL PROTECTED]> wrote: > Hi, > > Can you post a thread dump from the deadlock? > > My guess would be that we're using the second connection to fetch an > ID value from a sequence table. Otherwise, we sho

Connection usage

2007-08-23 Thread Christian Defoy
Hello, Quick question about connection usage: I was performing some tests and I noticed that my connection pool was configured for 10 connections but theoretically, I should need only one so I set the connection pool size to 1. Now, my application deadlocks because it appears that getEntityManag

Re: Detection of constraint violations

2007-08-21 Thread Christian Defoy
ED]> wrote: > Hmm. Do they get converted, or wrapped? If it's a complete conversion, > then we should do something to maintain that information, such as a > subtype of one of the PersistenceExceptions. > > Can you post the full stack trace that you're seeing? >

Re: Detection of constraint violations

2007-08-21 Thread Christian Defoy
gh. > > Can you post stacks that correspond to codes that we should also be catching? > > -Patrick > > On 8/21/07, Christian Defoy <[EMAIL PROTECTED]> wrote: > > Hello, > > > > I am looking for a way of programatically detecting whether an > > except

Detection of constraint violations

2007-08-21 Thread Christian Defoy
Hello, I am looking for a way of programatically detecting whether an exception was caused by a constraint violation. What is the best way to do that? The only way I have found so far is to navigate up the cause chain of the exception and see if one happens to be an SQLException and if so, get t

Re: Performance: single vs multiple transactions

2007-08-15 Thread Christian Defoy
Hi, To my understanding, this is a typical database behavior. If you perform massive operations within a single transaction, the db must account for everything in its log and it must lock all appropriate rows. In case of a rollback, your db will also have a lot of work to do... It is usually po

Re: OpenJPA is not inserting the parent reference on update

2007-08-13 Thread Christian Defoy
Hi! I managed to get around the problem by invoking manager.remove() on my Attachment object before replacing it with the one. It seems to work so far... Prior to that, I was almost successfull by detaching my Shape object prior to replacing its Attachment object. But then, when the Attachment

Re: OpenJPA is not inserting the parent reference on update

2007-07-26 Thread Christian Defoy
ex3.Attachment ex3.Note Hope this sheds some light on the problem! Christian On 7/25/07, Patrick Linskey <[EMAIL PROTECTED]> wrote: Hi, It sounds like a foreign key ordering problem. What db are you using? Can you post your persistence.xml properties? -Patrick On 7/25/07, Christi

OpenJPA is not inserting the parent reference on update

2007-07-25 Thread Christian Defoy
Hello, For some reason, I am unable to update an object that is already persisted. Here's how it goes: I have a Shape object that includes an Attachment. This is already saved in the database. I update the Shape by replacing its Attachment object with a new one that contains a Note object:

Re: Multiple selects when using entityManager.find()

2007-07-25 Thread Christian Defoy
Kevin On 7/24/07, Craig L Russell <[EMAIL PROTECTED]> wrote: > > This sounds a lot like https://issues.apache.org/jira/browse/OPENJPA-281 > > Craig > > On Jul 24, 2007, at 1:27 PM, Christian Defoy wrote: > > > Oups! I forgot to include it: > > > > p

Re: Multiple selects when using entityManager.find()

2007-07-24 Thread Christian Defoy
uce only one select > statement... And ShapeTypes is an enum? -Patrick On 7/24/07, Christian Defoy <[EMAIL PROTECTED]> wrote: > Hi Patrick, > > I have two classes. I stripped the accessors and mutators to shrink > them a bit (I am unsure if attachments get stripped or not).

Re: Multiple selects when using entityManager.find()

2007-07-24 Thread Christian Defoy
7/24/07, Patrick Linskey <[EMAIL PROTECTED]> wrote: Can you post the selects that you're seeing and the domain model? Thanks, -Patrick On 7/24/07, Christian Defoy <[EMAIL PROTECTED]> wrote: > Hello, > > I just noticed that if I call entityManager.find() to retrieve an &

Multiple selects when using entityManager.find()

2007-07-24 Thread Christian Defoy
Hello, I just noticed that if I call entityManager.find() to retrieve an object, many select statements (one per relation) are generated even though the relations are marked as FetchType.EAGER. If I use a JPQL query instead, only one select statement is generated. The JPQL looks like this: "SELE

How to filter set

2007-07-22 Thread Christian Defoy
Hello, I am looking for a way to filter a set while loading it into an object. For example, if class Shape contains a reference to a set of Drawings but the drawings are never deleted from the database but retired instead. How do I fill the attribute Shape.activeDrawings? The JPQL-like way of

Re: Bulk update with Enums

2007-07-20 Thread Christian Defoy
ues.apache.org/jira/browse/OPENJPA ? On Jul 20, 2007, at 7:07 AM, Christian Defoy wrote: > Hi, > > I am trying to do a bulk update on entities to set an attribute. This > attribute is an enum. If I put the enum in the update statement as in > the following: > > UPDATE Sha

Bulk update with Enums

2007-07-20 Thread Christian Defoy
Hi, I am trying to do a bulk update on entities to set an attribute. This attribute is an enum. If I put the enum in the update statement as in the following: UPDATE Shape s SET s.type = :type WHERE s.id = :id and I set the "type" parameter with: query.setParameter( "type", ShapeType.SQUARE

Re: Getting a group of entities by ID

2007-07-18 Thread Christian Defoy
l missing objects or one for each. You might want to turn on > SQL > logging to check, > > ((OpenJPAEntityManager) em).findAll(...) > > Hope this helps, > > David > > Christian Defoy wrote: >> Hello, >> >> I can't find an easy way of retrieving a group

Re: Getting a group of entities by ID

2007-07-18 Thread Christian Defoy
QL statement for all missing objects or one for each. You might want to turn on SQL logging to check, ((OpenJPAEntityManager) em).findAll(...) Hope this helps, David Christian Defoy wrote: > Hello, > > I can't find an easy way of retrieving a group of entities by > specifying

Getting a group of entities by ID

2007-07-18 Thread Christian Defoy
Hello, I can't find an easy way of retrieving a group of entities by specifying only their IDs. For example, if I want to get shapes with IDs 1, 2, 4 and 6, do I have to do the following query or is there a better way? SELECT x FROM shape x WHERE x.id = 1 OR x.id = 2 OR x.id = 4 OR x.id = 6 I w

Re: Persistence of EnumSet

2007-07-16 Thread Christian Defoy
unable to reach apache.org reliably. -Patrick On 7/13/07, Christian Defoy <[EMAIL PROTECTED]> wrote: > I tried with the following annotations: > @Persistent > @Type( String.class ) > @Externalizer( "Shape.typesToString" ) > @Factory( "Shape.typesFrom

Re: Persistence of EnumSet

2007-07-13 Thread Christian Defoy
@Type(String.class) on the field as well. -Patrick On 7/13/07, Christian Defoy <[EMAIL PROTECTED]> wrote: > Hi Patrick, > > Thanks for the answer. You guess correctly when you say that I want a > stringified version of my EnumSet. :) > > I tried to simply mark it @Persist

Re: Persistence of EnumSet

2007-07-13 Thread Christian Defoy
into the first case, we'll need to change OpenJPA to allow bypassing of proxy logic somehow. Also, we should probably allow field-by-field enabling of a more-expensive dirty checking strategy so that you don't need to manually mark the field as dirty. -Patrick On 7/13/07, Christian Defoy &l

Persistence of EnumSet

2007-07-13 Thread Christian Defoy
Hello! Is there a way to persist an EnumSet easily with OpenJPA? I tried with an externalizer: @PersistentCollection @Externalizer( "test.Shape.typesToString" ) @Factory( "test.Shape.typesFromString" ) @ElementType( String.class ) @Column( name="shape_types" ) private EnumSet

Re: Embedded entities are deleted last

2007-07-09 Thread Christian Defoy
! Christian On 7/9/07, Markus Fuchs <[EMAIL PROTECTED]> wrote: Hi Christian, I declared the connection properties in persistence.xml. That's the only difference from your setup. Could you try that? -- markus. Christian Defoy wrote: Hi Markus, I just tried with OpenJPA 1.0.0-snapshot.

Re: Embedded entities are deleted last

2007-07-09 Thread Christian Defoy
rading! -- markus. Christian Defoy wrote: > Hi Markus, > > I am using OpenJPA version 0.9.7. If you think it could help, I will > try today with nightly build for 1.0.0. I will also give it a try on > MSSQL as it is the other typ eof database we are using. > > When you sa

Re: Embedded entities are deleted last

2007-07-09 Thread Christian Defoy
order? Embedded before main? Thanks! Christian On 7/6/07, Markus Fuchs <[EMAIL PROTECTED]> wrote: Hi Christian, I can not reproduce your problem. I ran against Derby, my test environment and output is attached. Are you using a current OpenJPA distribution? -- markus. Christian Defoy

Re: Embedded entities are deleted last

2007-07-05 Thread Christian Defoy
Hi Markus, Here is the code to reproduce the problem. I include the source code, my persistence.xml file and the schema script for my database. As I mentionned in my first post, I am using Hypersonic (in case it is important). Shape.java: import javax.persistence.*; @Entity @Table(name="

Re: Embedded entities are deleted last

2007-07-04 Thread Christian Defoy
Hi again! This does make sense as I am trying to get the embedded classes to be mapped in secondary tables. Section 9.1.33 of the spec says that implementors are not required to support embedded objects that are mapped across multiple tables. But that part seems to work just fine with OpenJPA..

Re: Embedded entities are deleted last

2007-06-29 Thread Christian Defoy
s identity is defined by the identity of the owning record. Does this make sense in your environment? -Patrick On 6/28/07, Christian Defoy <[EMAIL PROTECTED]> wrote: > Hello! > > I am trying to get the existing object model from our system to > persist correctly with openjpa.

Embedded entities are deleted last

2007-06-28 Thread Christian Defoy
Hello! I am trying to get the existing object model from our system to persist correctly with openjpa. Here's the situation. I have an object A that contains a link to objects B and C. A will contain either a link to B or a link to C, never to both. I tried two approaches with openjpa to pers