Re: Violation of unique constraint $$: duplicate value(s) for column

2009-12-08 Thread cmoulliard

I have set the field name with a default value in the class ProcessDefinition
but the error is still there. If I remove the annotation on the method
getName, it works !!!

//@Column(unique = true) 
public String getName() {
return name;
}

What is the solution for HSQL DB ?

Remark : Even if the reason of the message displayed in the error is that
the field null, the message displayed is not very helpfull for the user
(Violation of unique constraint $$: duplicate value(s) for column) -- must
Violation of unique constraint $$: cannot insert null value(s) for column
!!!

Regards,

Charles


Daryl Stultz wrote:
 
 On Mon, Dec 7, 2009 at 11:37 AM, KARR, DAVID (ATTCINW)
 dk0...@att.comwrote:
 
 It doesn't make sense to have a unique constraint on a
 NULLABLE column.

 
 I disagree. A property can be optional and be required to be unique when
 it
 is specified. In my application I have such a case. I omitted the Unique
 annotation from my class but left the constraint in the database (OpenJPA
 refused to insert null into a foreign key column). Using PostgreSQL, nulls
 are ignored regarding uniqueness.
 
 -- 
 Daryl Stultz
 _
 6 Degrees Software and Consulting, Inc.
 http://www.6degrees.com
 mailto:da...@6degrees.com
 
 

-- 
View this message in context: 
http://n2.nabble.com/Violation-of-unique-constraint-duplicate-value-s-for-column-tp4126767p4131234.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Eclipse WTP tomcat plugin

2009-12-08 Thread Adam Hardy
I had to give up trying to get the javaagent to run on Eclipse Tomcat plugin. 
Maybe it works, maybe it doesn't, I can't really tell at tomcat startup and the 
problem is that every time I make a request, I see ClassNotFound errors.


I think the ClassNotFound errors arise from the requirement to have OpenJPA.jar 
in the classpath for the server rather than the app. Ditto for the other jars 
that OpenJPA depends on.


So I figure it is a class loading issue with the classes loaded by javaagent 
then becoming inaccessible to the webapp.


Pure speculation though.

Adam

Adam Hardy on 07/12/09 19:24, wrote:
I'm using the Eclipse Galileo and WTP to run an embedded instance of 
tomcat in Eclipse and I am trying to run enhancement on my webapp's 
entities using any means possible but am having no luck so far.


The furthest I get is with the javaagent as a parameter on the tomcat 
launch config. However this fails when I try to specify the 
persistence.xml file. I tried:


-javaagent:/disk2/java/m2-repo/org/apache/openjpa/openjpa/1.2.2-SNAPSHOT/openjpa-1.2.2-SNAPSHOT.jar=properties=persistence.xml#OpenJpaJdbc 



and I get this:

 by: java.util.MissingResourceException: persistence.xml#OpenJpaJdbc
at 
org.apache.openjpa.lib.conf.ProductDerivations.load(ProductDerivations.java:272) 

at 
org.apache.openjpa.lib.conf.Configurations.populateConfiguration(Configurations.java:344) 

at 
org.apache.openjpa.enhance.PCEnhancerAgent.registerClassLoadEnhancer(PCEnhancerAgent.java:101) 

at 
org.apache.openjpa.enhance.PCEnhancerAgent.premain(PCEnhancerAgent.java:82)

... 6 more

The line works fine when I'm using it as a parameter to run junit tests, 
but not here.


I can see that Eclipse-Tomcat has put the persistence.xml file deep in 
its directory structure somewhere, but giving the full path as a 
parameter didn't help anyway, it should be picked up from the classpath, 
I assume.


Does anyone have this working?


Re: Violation of unique constraint $$: duplicate value(s) for column

2009-12-08 Thread cmoulliard

I have set the field name with a default value in the class ProcessDefinition
but the error is still there. If I remove the annotation on the method
getName, it works !!!

//@Column(unique = true) 
public String getName() {
return name;
}

What is the solution for HSQL DB ?

Remark : Even if the reason of the message displayed in the error is that
the field null, the message displayed is not very helpfull for the user
(Violation of unique constraint $$: duplicate value(s) for column) -- must
Violation of unique constraint $$: cannot insert null value(s) for column
!!!

Regards,

Charles


Daryl Stultz wrote:
 
 On Mon, Dec 7, 2009 at 11:37 AM, KARR, DAVID (ATTCINW)
 dk0...@att.comwrote:
 
 It doesn't make sense to have a unique constraint on a
 NULLABLE column.

 
 I disagree. A property can be optional and be required to be unique when
 it
 is specified. In my application I have such a case. I omitted the Unique
 annotation from my class but left the constraint in the database (OpenJPA
 refused to insert null into a foreign key column). Using PostgreSQL, nulls
 are ignored regarding uniqueness.
 
 -- 
 Daryl Stultz
 _
 6 Degrees Software and Consulting, Inc.
 http://www.6degrees.com
 mailto:da...@6degrees.com
 
 

-- 
View this message in context: 
http://n2.nabble.com/Violation-of-unique-constraint-duplicate-value-s-for-column-tp4126767p4131845.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Violation of unique constraint $$: duplicate value(s) for column

2009-12-08 Thread Daryl Stultz
On Tue, Dec 8, 2009 at 4:00 AM, Thomas Polliard tho...@polliard.com wrote:

 Perhaps I dont understand your goals but.


 If you intend for the field to ALWAYS have a value for the row to be valid
 then NOT NULL is required.  If you intend for the rows to be unique but dont
 require the field for the row to be valid, it might make more sense to use a
 separate table.  Having a column on a table that is UNIQUE but NULLABLE is a
 bad design and can lead to confusion.


I have a users table with a timecardid column. A user may or may not have a
timecardid (it's just a text value, not a foreign key). If they have it, it
must be unique (nulls excluded). DDL looks like this:

CREATE TABLE users (
userid integer NOT NULL,
...
timecardid character varying(50),
...
);

CREATE UNIQUE INDEX users_timecardid_unq ON users USING btree (timecardid);

It accepts nulls and rejects (non-null) duplicates:

db=# select count(*) from users where timecardid is null;
  count
---
62
(1 row)

There are often a variety of ways of physically modelling the logical
design. Adding a one-to-one table adds an unnecessary complication. What's
confusing about it's optional but needs to be unique if provided?

-- 
Daryl Stultz
_
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:da...@6degrees.com


Re: Eclipse WTP tomcat plugin

2009-12-08 Thread Rick Curtis

Adam -

Have you tried setting the javaagent without the =properties=persis ?
Another option would be build/package time enhancement?

Thanks,
Rick

Adam Hardy-4 wrote:
 
 I'm using the Eclipse Galileo and WTP to run an embedded instance of
 tomcat in 
 Eclipse and I am trying to run enhancement on my webapp's entities using
 any 
 means possible but am having no luck so far.
 
 The furthest I get is with the javaagent as a parameter on the tomcat
 launch 
 config. However this fails when I try to specify the persistence.xml file.
 I tried:
 
 -javaagent:/disk2/java/m2-repo/org/apache/openjpa/openjpa/1.2.2-SNAPSHOT/openjpa-1.2.2-SNAPSHOT.jar=properties=persistence.xml#OpenJpaJdbc
 
 and I get this:
 
   by: java.util.MissingResourceException: persistence.xml#OpenJpaJdbc
   at
 org.apache.openjpa.lib.conf.ProductDerivations.load(ProductDerivations.java:272)
   at 
 org.apache.openjpa.lib.conf.Configurations.populateConfiguration(Configurations.java:344)
   at 
 org.apache.openjpa.enhance.PCEnhancerAgent.registerClassLoadEnhancer(PCEnhancerAgent.java:101)
   at
 org.apache.openjpa.enhance.PCEnhancerAgent.premain(PCEnhancerAgent.java:82)
   ... 6 more
 
 The line works fine when I'm using it as a parameter to run junit tests,
 but not 
 here.
 
 I can see that Eclipse-Tomcat has put the persistence.xml file deep in its 
 directory structure somewhere, but giving the full path as a parameter
 didn't 
 help anyway, it should be picked up from the classpath, I assume.
 
 Does anyone have this working?
 
 Thanks
 Adam
 
 

-- 
View this message in context: 
http://n2.nabble.com/Eclipse-WTP-tomcat-plugin-tp4127982p4133887.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Ideas for fetching shallow composition tree?

2009-12-08 Thread KARR, DAVID (ATTCINW)
Let's say that I have an entity called Category in a composition
relationship with itself.  The depth of these relationships won't be
very deep, perhaps 2-3 deep at the most.  I'm considering whether it's
possible to efficiently retrieve the entire composition tree with eager
fetches, even if these relationships are lazy by default.  I know I can
fetch one level at a time in an eager fashion, but is there any way to
have a single query assemble more than one level, or the entire
composition tree?