nested exception is openjpa-0.0.0-rnull nonfatal store error org.apache.openjpa.persistence.Entity NotFoundException

2009-12-07 Thread Charles Moulliard
Hi,

I have a Apache Camel project where we use openJPA as an JPA component of
camel (http://camel.apache.org/jpa.html). Spring is used to facilitate db
connection, transaction handling and so on.

Unforunately, our code does not work anymore and generate the following
error. IT works fine when using Hibernate as JPA framework with Spring

[ Camel thread 1: FileComponent] GenericFileOnCompletionERROR The
instance of type class org.apache.camel.example.etl.CustomerEntity with oi
d org.apache.camel.example.etl.CustomerEntity-100 no longer exists in the
data store.  This may mean that you deleted the instance in a separate tra
nsaction, but this context still has a cached version.; nested exception is
openjpa-0.0.0-rnull nonfatal store error org.apache.openjpa.persistence.
EntityNotFoundException: The instance of type class
org.apache.camel.example.etl.CustomerEntity with oid
org.apache.camel.example.etl.CustomerEntit
y-100 no longer exists in the data store.  This may mean that you deleted
the instance in a separate transaction, but this context still has a cached
 version.
FailedObject:
org.apache.camel.example.etl.CustomerEntity-org.apache.camel.example.etl.CustomerEntity-100
org.springframework.orm.jpa.JpaObjectRetrievalFailureException: The instance
of type class org.apache.camel.example.etl.CustomerEntity with oid org
.apache.camel.example.etl.CustomerEntity-100 no longer exists in the data
store.  This may mean that you deleted the instance in a separate transacti
on, but this context still has a cached version.; nested exception is
openjpa-0.0.0-rnull nonfatal store error
org.apache.openjpa.persistence.Entity
NotFoundException: The instance of type class
org.apache.camel.example.etl.CustomerEntity with oid
org.apache.camel.example.etl.CustomerEntity-100
 no longer exists in the data store.  This may mean that you deleted the
instance in a separate transaction, but this context still has a cached
versi
on.
FailedObject:
org.apache.camel.example.etl.CustomerEntity-org.apache.camel.example.etl.CustomerEntity-100
at
org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:276)
at
org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:120)
at
org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:212)
at
org.springframework.orm.jpa.JpaAccessor.translateIfNecessary(JpaAccessor.java:152)
at
org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:189)
at
org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:147)
at
org.apache.camel.component.jpa.JpaTemplateTransactionStrategy$1.doInTransaction(JpaTemplateTransactionStrategy.java:79)
at
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
at
org.apache.camel.component.jpa.JpaTemplateTransactionStrategy.execute(JpaTemplateTransactionStrategy.java:77)
at
org.apache.camel.component.jpa.JpaProducer.process(JpaProducer.java:49)
at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:97)
at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:94)
at
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
at
org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94)
at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:162)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:223)
at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:153)
at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
at
org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:206)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
at
org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:54)
at
org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
at

RE: Fetch plan question

2009-12-07 Thread Michael Vorburger
 how to dynamically, using fetch plan, exclude (rather than adding) to
the fetch plan some attribute not to retrieve 

I probably misunderstand, but doesn't FetchPlan.clearFields() +
FetchPlan.clearFetchGroups() followed by a few addField() do what you
want (I haven't tried) ?

http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/docs/javadoc
/org/apache/openjpa/persistence/FetchPlan.html


Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

2009-12-07 Thread himadri



Hi,

This is strange. The problem comes when I add Child Associations to the entity. 
If I remove Child Asscoiations , all work fine. I have attached my Sample here. 
Please see JPG for Entity Associations. SampleEJB.ear is the deployable ear on 
WL10.3. 

Let me know if you find out anything .. for now I have replace all em.find with 
em.createQuery(Select ...) , But will like to know the real reason behind it ! 

Lemme know if I can provide more simplified sample 

Thanks,
Himadri 



From: Kevin Sutter [via OpenJPA] ml-node+4103283-1191879...@n2.nabble.com
To: himadri hima_...@yahoo.co.in
Sent: Thu, 3 December, 2009 5:39:17 AM
Subject: Re: Open JPA generates incorrect Union All for Date and Boolean 
Datatype

This sounds very strange.  From your description, I have no idea why Date 
and Boolean attributes are having problems with Oracle.  And, why a Union 
All is being generated for a simple find operation baffles me as well. 
Unless there is some inheritance or eagerly fetched relationships involved. 
Still, I thought OpenJPA used Joins over Unions. 

Can you simplify the problem to a simple testcase that could be provided? 

Thanks, 
Kevin 

On Tue, Dec 1, 2009 at 7:15 AM, himadri [hidden email] wrote: 


 
 Hi, 
 
 I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g DB. I 
 have an entity Typed which has Date and Boolean datatypes. em.persist is 
 sucessful. 
 
 But whereever there is em.find() on any entity in this application , I have 
 observed that open JPA  tries to get Union  of all entities. This may be 
 because its first time , But it fails with exception 
 
 [BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same 
 datatype as corresponding expression 
 
 The SQL generated is union all of all entities in the application . For 
 boolean FLAG_F , MOMENT_F wrong sql is generated. It should have to_date 
 function for date. I have used DATE and boolean in Entity class. 
 
 SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0, 
 '1970-01-01', 
 '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ? 
 UNION ALL 
 SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, 
 t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 
 WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790, state=HY000] 
 
 I guess openJPA fails to add to_date function for DATE and surrounding 
 chars 
 for boolean. Is this a bug or some settings available.  Why is it trying to 
 get union all even for em.find(... ) ? 
 
 Thanks in advance.. 
 - H 
 
 
 
 
 
 
 -- 
 View this message in context: 
 http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
 Sent from the OpenJPA Users mailing list archive at Nabble.com. 
 




View message @ 
http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4103283.html
 
To unsubscribe from Open JPA generates incorrect Union All for Date and Boolean 
Datatype, click here. 



  The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. 
http://in.yahoo.com/
 
-- 
View this message in context: 
http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4126266.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Fetch plan question

2009-12-07 Thread Jean-Baptiste BRIAUD -- Novlog
In fact, when I call, for debugging purpose, the fetchPlan.getFields() methods, 
I can check that the field I need and only the fields I need are there.
= the fetchPlan itself is correct.

Then, what should I do to use the fetchplan ? I can't find my old test that 
was pure OpenJPA (without all my application code I have now) but I remember I 
can use entityManager just as simply as without fetchplan.
The fact to create and set a fetchplan from that entityManager is enough to 
tell the entityManager to use it. 

Am i right ?

Also, here in the doc : 
http://openjpa.apache.org/builds/1.0.2/apache-openjpa-1.0.2/docs/manual/ref_guide_fetch.html
I read that example :

   OpenJPAEntityManager kem = OpenJPAPersistence.cast(em);
   kem.getFetchPlan().addField(Magazine.class, publisher);
   Magazine mag = em.find(Magazine.class, magId);

Will it work also with a query and not only with the find(id) method ?
Something like that : em.createQuery(SELECT blablabla ...); ??


On Dec 7, 2009, at 15:20 , Jean-Baptiste BRIAUD -- Novlog wrote:

 I call this 2 methods before adding the fields I want but still it doesn't 
 behave like expected.
 
 On Dec 7, 2009, at 13:00 , Michael Vorburger wrote:
 
 how to dynamically, using fetch plan, exclude (rather than adding) to
 the fetch plan some attribute not to retrieve 
 
 I probably misunderstand, but doesn't FetchPlan.clearFields() +
 FetchPlan.clearFetchGroups() followed by a few addField() do what you
 want (I haven't tried) ?
 
 http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/docs/javadoc
 /org/apache/openjpa/persistence/FetchPlan.html
 
 
 



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

2009-12-07 Thread Charles Moulliard
Hi,

I use openjpa version 1.3-snasphot and the following entity class which is
used in my application  generates the following error :

@Entity
@Table(
name = CAMEL_ACTIVITYDEFINITION,
uniqueConstraints = @UniqueConstraint(columnNames = {name})
)
public class ActivityDefinition extends EntitySupport {
private String name;
private ProcessDefinition processDefinition;

// This crap is required to work around a bug in hibernate
@Override
@Id
@GeneratedValue
public Long getId() {
return super.getId();
}

@Override
public String toString() {
return Activity[ + getId() +  name:  + getName() + ];
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST,
CascadeType.MERGE })
public ProcessDefinition getProcessDefinition() {
return processDefinition;
}

public void setProcessDefinition(ProcessDefinition processDefinition) {
this.processDefinition = processDefinition;
}
}


ERROR :

Caused by: openjpa-1.3.0-SNAPSHOT-r422266:881892 nonfatal general error
org.apache.openjpa.persistence.PersistenceException: Violation of unique
constraint $$: duplicate value(s) for column(s) $$: U_CML_NTN_NAME in
statement [INSERT INTO CAMEL_PROCESSDEFINITION (id, name) VALUES (?, ?)]
{prepstmnt 30276889 INSERT INTO CAMEL_PROCESSDEFINITION (id, name) VALUES
(?, ?) [params=(long) 7, (String) ]} [code=-104, state=23000]
FailedObject: org.apache.camel.bam.model.processdefinit...@17fc44f
at
org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4351)
at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4316)
at
org.apache.openjpa.jdbc.sql.HSQLDictionary.newStoreException(HSQLDictionary.java:292)
at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:127)
at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:80)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:93)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:81)
at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:549)
at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:106)
at
org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:89)
at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:72)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:719)
at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
... 29 more
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Violation of
unique constraint $$: duplicate value(s) for column(s) $$: U_CML_NTN_NAME in
statement [INSERT INTO CAMEL_PROCESSDEFINITION (id, name) VALUES (?, ?)]
{prepstmnt 30276889 INSERT INTO CAMEL_PROCESSDEFINITION (id, name) VALUES
(?, ?) [params=(long) 7, (String) ]} [code=-104, state=23000]
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:193)
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:58)
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:983)
at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1601)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:220)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:112)
... 39 more

Can someone tells me how to avoid that ?

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
Linkedlin : http://www.linkedin.com/in/charlesmoulliard

Apache Camel Group :
http://www.linkedin.com/groups?home=gid=2447439trk=anet_ug_hm


MappedSuperclasses?

2009-12-07 Thread Laird Nelson
Hello; I asked this question before and got crickets.

What is the best way to customize a ReverseMappingTool run such that for
every table mapped I create a MappedSuperclass that it inherits from?

I am using OpenJPA 1.2.1 and generating annotations, not XML.

So if I have a database table named Person, then I want a
PersonMappedSuperclass.java and a Person.java class that inherits from it.

I am so close it is maddening, but cannot cross the final chasm.

The first thing I do is to set my ReverseCustomizer to change the incoming
ClassMapping to setEmbeddedOnly(true), and rename it to
xyzMappedSuperclass.  Then I generate a new class, set the MappedSuperclass
as its parent, and install the new mapping directly into the repository,
like so (inside customize(ClassMapping)):

mapping.setEmbeddedOnly(true);

final Class? mappingClass = mapping.getDescribedType();
final String mappingClassName = mappingClass.getName();

final String newClassName = mappingClassName.substring(0,
mappingClassName.length() - MappedSuperclass.length());
final Class? newClass = this.tool.generateClass(newClassName,
mappingClass);

final MappingRepository mappingRepository = this.tool.getRepository();

final ClassMapping newMapping =
(ClassMapping)mappingRepository.addMetaData(newClass);
newMapping.setPCSuperclass(mappingClass);
newMapping.setTable(mapping.getTable()); // ? maybe?
newMapping.setEmbeddedOnly(false);

This does more or less what I want: at the end of this run, I get a mapped
superclass and an entity class that extends from it.  However, none of the
mapped superclass field information is filled in.  That is, I get things
like:

@Basic

Instead of

@Basic
@Column(name=pmt_no, length=16)

Bug 1360 seems to be related to this (
http://issues.apache.org/jira/browse/OPENJPA-1360).  It would appear that in
the 1.2.x line, anyhow, it is impossible to create a MappedSuperclass whose
field annotations are properly filled in, thus of course defeating the
entire purpose of a MappedSuperclass.  I would be interested to learn if
ANYONE has ever generated MappedSuperclasses using this tool.

Best,
Laird


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

2009-12-07 Thread KARR, DAVID (ATTCINW)
 -Original Message-
 From: Charles Moulliard [mailto:cmoulli...@gmail.com]
 Sent: Monday, December 07, 2009 8:05 AM
 To: users@openjpa.apache.org
 Subject: Violation of unique constraint $$: duplicate value(s) for
 column
 
 Hi,
 
 I use openjpa version 1.3-snasphot and the following entity class
which
 is
 used in my application  generates the following error :
 
 [deleted]
 ERROR :
 
 Caused by: openjpa-1.3.0-SNAPSHOT-r422266:881892 nonfatal general
 error
 org.apache.openjpa.persistence.PersistenceException: Violation of
 unique
 constraint $$: duplicate value(s) for column(s) $$: U_CML_NTN_NAME in
 statement [INSERT INTO CAMEL_PROCESSDEFINITION (id, name) VALUES (?,
 ?)]
 {prepstmnt 30276889 INSERT INTO CAMEL_PROCESSDEFINITION (id, name)
 VALUES
 (?, ?) [params=(long) 7, (String) ]} [code=-104, state=23000]

It sure looks to me like you're trying to insert a row with a NULL
name value.  It doesn't make sense to have a unique constraint on a
NULLABLE column.


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

2009-12-07 Thread Daryl Stultz
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


Re: MappedSuperclasses?

2009-12-07 Thread Kevin Sutter
Hi Laird,
I'm not much better than a cricket with this particular question, but I have
a couple of observations...

Since you are attempting to affect the execution of the ReverseMappingTool,
you may be a little beyond basic usage questions.  Thus, I'm going to
cross-copy this question over the dev mailing list.  Not guaranteeing
activity because of this since most of us monitor both mailing lists.  But,
it won't hurt in this case...

One thing to keep in mind is that the ReverseMappingTool is not meant to be
the end-all tool for generating the Entity classes.  It is expected that
tweaking of the generated code will be necessary to make your Entities
production ready.  Now, if the generated code is not syntactically correct
or complete, then that's another issue.  But, personally, I wouldn't expect
the generated code to be complete.

If you continue to only get crickets responding to the request, then this
may indicate a lack of resource or even a lack of expertise on your
particular question.  It may also be an excellent opportunity for you to
roll up your sleeves, debug the problem, and contribute a solution back to
the community.  We are always looking for new blood.  :-)

Good luck,
Kevin


On Mon, Dec 7, 2009 at 10:29 AM, Laird Nelson ljnel...@gmail.com wrote:

 Hello; I asked this question before and got crickets.

 What is the best way to customize a ReverseMappingTool run such that for
 every table mapped I create a MappedSuperclass that it inherits from?

 I am using OpenJPA 1.2.1 and generating annotations, not XML.

 So if I have a database table named Person, then I want a
 PersonMappedSuperclass.java and a Person.java class that inherits from it.

 I am so close it is maddening, but cannot cross the final chasm.

 The first thing I do is to set my ReverseCustomizer to change the incoming
 ClassMapping to setEmbeddedOnly(true), and rename it to
 xyzMappedSuperclass.  Then I generate a new class, set the MappedSuperclass
 as its parent, and install the new mapping directly into the repository,
 like so (inside customize(ClassMapping)):

mapping.setEmbeddedOnly(true);

final Class? mappingClass = mapping.getDescribedType();
final String mappingClassName = mappingClass.getName();

final String newClassName = mappingClassName.substring(0,
 mappingClassName.length() - MappedSuperclass.length());
final Class? newClass = this.tool.generateClass(newClassName,
 mappingClass);

final MappingRepository mappingRepository = this.tool.getRepository();

final ClassMapping newMapping =
 (ClassMapping)mappingRepository.addMetaData(newClass);
newMapping.setPCSuperclass(mappingClass);
newMapping.setTable(mapping.getTable()); // ? maybe?
newMapping.setEmbeddedOnly(false);

 This does more or less what I want: at the end of this run, I get a mapped
 superclass and an entity class that extends from it.  However, none of the
 mapped superclass field information is filled in.  That is, I get things
 like:

@Basic

 Instead of

@Basic
@Column(name=pmt_no, length=16)

 Bug 1360 seems to be related to this (
 http://issues.apache.org/jira/browse/OPENJPA-1360).  It would appear that
 in
 the 1.2.x line, anyhow, it is impossible to create a MappedSuperclass whose
 field annotations are properly filled in, thus of course defeating the
 entire purpose of a MappedSuperclass.  I would be interested to learn if
 ANYONE has ever generated MappedSuperclasses using this tool.

 Best,
 Laird



Re: MappedSuperclasses?

2009-12-07 Thread ljnelson

Sure, Kevin; that's a fair answer.

I know that the root issue lies in the double-purposing of the
ClassMetaData.isEmbeddedOnly() method.  It is used both to determine whether
a class should be an @Embedded, and it is also used to determine whether a
class should be a @MappedSuperclass (!).  I understand that the latter
condition has been solved by the addition of the isAbstract() method in
OpenJPA 2.0.x.

Anyhow, this isn't by itself all that bad.

What may be bad is that there are several calls made to
AnnotationPersistenceMappingSerializer#isMappingMode(ClassMetaData), and its
default behavior is to consider whether the passed in ClassMetaData is
embedded or not.  This drives, among other things, whether field mappings
retain all their attributes (like name), but unfortunately it also drives
whether mapped superclasses get an @Entity or a @MappedSuperclass tag.

So if you set a ClassMapping#isEmbedded() one way, you get mapped
superclasses correctly annotated as @MappedSuperclass, but all the field
annotations are empty.  If you set it the other way, you get all the field
annotations populated, but the class gets an @Entity tag.  See bug 1360 for
more details there.

The way that I've almost solved the problem--but boy does it feel wrong!--is
to install my own subclass of AnnotationPersistenceMappingSerializer so that
isEmbeddedOnly() is simply not considered in the implementation of
isMappingMode(ClassMetaData).  This is just fine--the only remaining hurdle
that I think I'm hearing is probably not going to be fixed anytime soon
unless I wade in with a hammer and try to fix it myself :-) is that the
@MappedSuperclass gets a @Table annotation.

Thanks for the non-silence :-)

Best,
Laird

On Mon, Dec 7, 2009 at 12:45 PM, Kevin Sutter [via OpenJPA] 
ml-node+4127373-1333037...@n2.nabble.comml-node%2b4127373-1333037...@n2.nabble.com
 wrote:

 Hi Laird,
 I'm not much better than a cricket with this particular question, but I
 have
 a couple of observations...

 Since you are attempting to affect the execution of the ReverseMappingTool,

 you may be a little beyond basic usage questions.  Thus, I'm going to
 cross-copy this question over the dev mailing list.  Not guaranteeing
 activity because of this since most of us monitor both mailing lists.  But,

 it won't hurt in this case...

 One thing to keep in mind is that the ReverseMappingTool is not meant to be

 the end-all tool for generating the Entity classes.  It is expected that
 tweaking of the generated code will be necessary to make your Entities
 production ready.  Now, if the generated code is not syntactically
 correct
 or complete, then that's another issue.  But, personally, I wouldn't expect

 the generated code to be complete.

 If you continue to only get crickets responding to the request, then this
 may indicate a lack of resource or even a lack of expertise on your
 particular question.  It may also be an excellent opportunity for you to
 roll up your sleeves, debug the problem, and contribute a solution back to
 the community.  We are always looking for new blood.  :-)

 Good luck,
 Kevin


 On Mon, Dec 7, 2009 at 10:29 AM, Laird Nelson [hidden 
 email]http://n2.nabble.com/user/SendEmail.jtp?type=nodenode=4127373i=0
 wrote:

  Hello; I asked this question before and got crickets.
 
  What is the best way to customize a ReverseMappingTool run such that for
  every table mapped I create a MappedSuperclass that it inherits from?
 
  I am using OpenJPA 1.2.1 and generating annotations, not XML.
 
  So if I have a database table named Person, then I want a
  PersonMappedSuperclass.java and a Person.java class that inherits from
 it.
 
  I am so close it is maddening, but cannot cross the final chasm.
 
  The first thing I do is to set my ReverseCustomizer to change the
 incoming
  ClassMapping to setEmbeddedOnly(true), and rename it to
  xyzMappedSuperclass.  Then I generate a new class, set the
 MappedSuperclass
  as its parent, and install the new mapping directly into the repository,
  like so (inside customize(ClassMapping)):
 
 mapping.setEmbeddedOnly(true);
 
 final Class? mappingClass = mapping.getDescribedType();
 final String mappingClassName = mappingClass.getName();
 
 final String newClassName = mappingClassName.substring(0,
  mappingClassName.length() - MappedSuperclass.length());
 final Class? newClass = this.tool.generateClass(newClassName,
  mappingClass);
 
 final MappingRepository mappingRepository = this.tool.getRepository();

 
 final ClassMapping newMapping =
  (ClassMapping)mappingRepository.addMetaData(newClass);
 newMapping.setPCSuperclass(mappingClass);
 newMapping.setTable(mapping.getTable()); // ? maybe?
 newMapping.setEmbeddedOnly(false);
 
  This does more or less what I want: at the end of this run, I get a
 mapped
  superclass and an entity class that extends from it.  However, none of
 the
  mapped superclass field information is filled in.  That is, I get things
  like:
 

Eclipse WTP tomcat plugin

2009-12-07 Thread Adam Hardy
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


Re: Fetch plan question

2009-12-07 Thread Jean-Baptiste BRIAUD -- Novlog

On Dec 7, 2009, at 18:57 , Michael Vorburger wrote:

 Jean-Baptiste,
Hi Michael,
 
 I realized that in our own in-house framework to simply to the max the
 use of fetchPlan (just like yours... and ours?) we must be doing the
 same
we may share some ideas or some directions ...

 , so I refereshed my memories by looking back at that code for you
Thanks !

 (written over a year ago) and suddenly remembered that indeed there is a
 little trick, you have to:
 
   fp.removeFetchGroup(FetchGroup.NAME_DEFAULT);
 
It was that, a big big thanks.
I'm still wondering why the API do not provide a removeAllGroups and 
removeALLFields, so even without knowing the name of any groups or fields, the 
fetch plan would be 100% empty.

I thought that it was already done by that code :
final FetchPlan fetchPlan = entityManager.getFetchPlan();
fetchPlan.clearFetchGroups();
fetchPlan.clearFields();

Now, thanks to you, I'm doing the following :
final FetchPlan fetchPlan = entityManager.getFetchPlan();
fetchPlan.clearFetchGroups();
fetchPlan.clearFields();
fetchPlan.removeFetchGroup(FetchGroup.NAME_DEFAULT);

 Because (quote from doc) any field that is eagerly loaded according to
 the JPA metadata rules into the built-in default fetch group. As its
 name implies, the default fetch group is active by default. You may also
 define your own...
 
In fact, you right, I read that but I still thought I didn't have fetchGroup 
forgetting the default one.

 Does this help?  If yes, why don't you create a little Defect suggest
 that the documentation be slightly slightly improved to take this
 crystal clear?  Once you know it I guess the phrase above is clear, but
 if you don't, it's probably not clear enough?
Exactly that !

  A few lines of example  explanation may have helped you?
Yes definitively, I would have notices the extra 
fetchPlan.removeFetchGroup(FetchGroup.NAME_DEFAULT);
 
 
 Magazine mag = em.find(Magazine.class, magId);
 Will it work also with a query and not only with the find(id) method ?
 Something like that : em.createQuery(SELECT blablabla ...); ??
 
 Yes yes of course.  Make sure you also read  understand the
 http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/docs/manual/
 ref_guide_perfpack_eager.html stuff though.
 
OK, this was like others recents question a way to confirm what I try to do is 
correct. When something goes wrong, I always suspect my own understanding first.

 Ciao.
 
Thanks a lot, I could spent days without finding that default fetchgroup thing.



Re: Fetch plan question

2009-12-07 Thread Daryl Stultz
On Mon, Dec 7, 2009 at 3:48 PM, Jean-Baptiste BRIAUD -- Novlog 
j-b.bri...@novlog.com wrote:

 Now, thanks to you, I'm doing the following :
final FetchPlan fetchPlan = entityManager.getFetchPlan();
fetchPlan.clearFetchGroups();
fetchPlan.clearFields();
fetchPlan.removeFetchGroup(FetchGroup.NAME_DEFAULT);


FWIW, if you don't know already, modifying the fetch plan at the EM level
affects all subsequent queries. You can also modify the fetch plan for
individual queries.

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


RE: Fetch plan question

2009-12-07 Thread Michael Vorburger

https://issues.apache.org/jira/browse/OPENJPA-1416


Re: Fetch plan question

2009-12-07 Thread Jean-Baptiste BRIAUD -- Novlog
How do you do that ?

I'm using a new EM for one client-server network request but even in one 
client-server network request there may be several database request, so I would 
be interested to know how to you set a fetch plan for one request only.

On Dec 7, 2009, at 22:13 , Daryl Stultz wrote:

 On Mon, Dec 7, 2009 at 3:48 PM, Jean-Baptiste BRIAUD -- Novlog 
 j-b.bri...@novlog.com wrote:
 
 Now, thanks to you, I'm doing the following :
   final FetchPlan fetchPlan = entityManager.getFetchPlan();
   fetchPlan.clearFetchGroups();
   fetchPlan.clearFields();
   fetchPlan.removeFetchGroup(FetchGroup.NAME_DEFAULT);
 
 
 FWIW, if you don't know already, modifying the fetch plan at the EM level
 affects all subsequent queries. You can also modify the fetch plan for
 individual queries.
 
 -- 
 Daryl Stultz
 _
 6 Degrees Software and Consulting, Inc.
 http://www.6degrees.com
 mailto:da...@6degrees.com



Re: Fetch plan question

2009-12-07 Thread Craig L Russell


On Dec 7, 2009, at 1:44 PM, Jean-Baptiste BRIAUD -- Novlog wrote:


How do you do that ?

I'm using a new EM for one client-server network request but even in  
one client-server network request there may be several database  
request, so I would be interested to know how to you set a fetch  
plan for one request only.


There is a fetch plan for the em that can be modified. Subsequent  
operations use the modified fetch plan.


There is a fetch plan for a query that is initialized to the fetch  
plan for the em at the time you create the query. The fetch plan for  
the query can be modified and it only affects that query.


If you want to modify the fetch plan for a series of queries and then  
revert the fetch plan, take a look at  
OpenJPAEntityManager.pushFetchPlan and popFetchPlan.


Craig


On Dec 7, 2009, at 22:13 , Daryl Stultz wrote:


On Mon, Dec 7, 2009 at 3:48 PM, Jean-Baptiste BRIAUD -- Novlog 
j-b.bri...@novlog.com wrote:


Now, thanks to you, I'm doing the following :
 final FetchPlan fetchPlan = entityManager.getFetchPlan();
 fetchPlan.clearFetchGroups();
 fetchPlan.clearFields();
 fetchPlan.removeFetchGroup(FetchGroup.NAME_DEFAULT);


FWIW, if you don't know already, modifying the fetch plan at the EM  
level
affects all subsequent queries. You can also modify the fetch plan  
for

individual queries.

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




Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:craig.russ...@sun.com
P.S. A good JDO? O, Gasp!



smime.p7s
Description: S/MIME cryptographic signature


Re: Fetch plan question

2009-12-07 Thread Jean-Baptiste BRIAUD -- Novlog
HI Craig,

Wow, that fetchPlan API is just far more powerful than I thought. I'll have to 
dig that, I'm sure our OpenJPA layer need improvements :-)

OpenJPA really rocks !

On Dec 7, 2009, at 22:59 , Craig L Russell wrote:

 
 On Dec 7, 2009, at 1:44 PM, Jean-Baptiste BRIAUD -- Novlog wrote:
 
 How do you do that ?
 
 I'm using a new EM for one client-server network request but even in one 
 client-server network request there may be several database request, so I 
 would be interested to know how to you set a fetch plan for one request only.
 
 There is a fetch plan for the em that can be modified. Subsequent operations 
 use the modified fetch plan.
 
 There is a fetch plan for a query that is initialized to the fetch plan for 
 the em at the time you create the query. The fetch plan for the query can be 
 modified and it only affects that query.
 
 If you want to modify the fetch plan for a series of queries and then revert 
 the fetch plan, take a look at OpenJPAEntityManager.pushFetchPlan and 
 popFetchPlan.
 
 Craig
 
 On Dec 7, 2009, at 22:13 , Daryl Stultz wrote:
 
 On Mon, Dec 7, 2009 at 3:48 PM, Jean-Baptiste BRIAUD -- Novlog 
 j-b.bri...@novlog.com wrote:
 
 Now, thanks to you, I'm doing the following :
 final FetchPlan fetchPlan = entityManager.getFetchPlan();
 fetchPlan.clearFetchGroups();
 fetchPlan.clearFields();
 fetchPlan.removeFetchGroup(FetchGroup.NAME_DEFAULT);
 
 
 FWIW, if you don't know already, modifying the fetch plan at the EM level
 affects all subsequent queries. You can also modify the fetch plan for
 individual queries.
 
 -- 
 Daryl Stultz
 _
 6 Degrees Software and Consulting, Inc.
 http://www.6degrees.com
 mailto:da...@6degrees.com
 
 
 Craig L Russell
 Architect, Sun Java Enterprise System http://db.apache.org/jdo
 408 276-5638 mailto:craig.russ...@sun.com
 P.S. A good JDO? O, Gasp!
 



Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

2009-12-07 Thread Ravi P Palacherla

Looks like the SampleEJB.ear in the attachment is not a correct ear.
I am unable to deploy it on Weblogic server.

Also the configuration files (like persistence.xml) and entities are missing
in the attachment without which I may not be able to tell what configuration
you are using.

Are you using openJPA configurations or kodo configurations ?
There was a known issue with a CLOB data type when kodo configuration is
used. 
The fix for this is in kodo files, it overrides openJPA's classes in order
to fix it.

Before going into details of the fix, Please attach a replicable testcase.
That way I can see if the same fix applies for your scenario or not.

It would be great if you are able to replicate the issue with openJPA
configuration itself; we can work together on resolving the issue in openJPA
itself.

Also there were some workarounds of setting SubclassFetchMode=none;which I
would not completely recommend with out understanding your complete
environment.

Regards,
Ravi.


himadri wrote:
 
 
 
 Hi,
 
 This is strange. The problem comes when I add Child Associations to the
 entity. If I remove Child Asscoiations , all work fine. I have attached my
 Sample here. 
 Please see JPG for Entity Associations. SampleEJB.ear is the deployable
 ear on WL10.3. 
 
 Let me know if you find out anything .. for now I have replace all em.find
 with em.createQuery(Select ...) , But will like to know the real reason
 behind it ! 
 
 Lemme know if I can provide more simplified sample 
 
 Thanks,
 Himadri 
 
 
 
 From: Kevin Sutter [via OpenJPA]
 ml-node+4103283-1191879...@n2.nabble.com
 To: himadri hima_...@yahoo.co.in
 Sent: Thu, 3 December, 2009 5:39:17 AM
 Subject: Re: Open JPA generates incorrect Union All for Date and Boolean
 Datatype
 
 This sounds very strange.  From your description, I have no idea why Date 
 and Boolean attributes are having problems with Oracle.  And, why a Union 
 All is being generated for a simple find operation baffles me as well. 
 Unless there is some inheritance or eagerly fetched relationships
 involved. 
 Still, I thought OpenJPA used Joins over Unions. 
 
 Can you simplify the problem to a simple testcase that could be provided? 
 
 Thanks, 
 Kevin 
 
 On Tue, Dec 1, 2009 at 7:15 AM, himadri [hidden email] wrote: 
 
 
 
 Hi, 
 
 I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g DB.
 I 
 have an entity Typed which has Date and Boolean datatypes. em.persist is 
 sucessful. 
 
 But whereever there is em.find() on any entity in this application , I
 have 
 observed that open JPA  tries to get Union  of all entities. This may be 
 because its first time , But it fails with exception 
 
 [BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same 
 datatype as corresponding expression 
 
 The SQL generated is union all of all entities in the application . For 
 boolean FLAG_F , MOMENT_F wrong sql is generated. It should have to_date 
 function for date. I have used DATE and boolean in Entity class. 
 
 SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0, 
 '1970-01-01', 
 '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ? 
 UNION ALL 
 SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F,
 t0.ENUMED1_F, 
 t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T
 t0 
 WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790,
 state=HY000] 
 
 I guess openJPA fails to add to_date function for DATE and surrounding 
 chars 
 for boolean. Is this a bug or some settings available.  Why is it trying
 to 
 get union all even for em.find(... ) ? 
 
 Thanks in advance.. 
 - H 
 
 
 
 
 
 
 -- 
 View this message in context: 
 http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
 Sent from the OpenJPA Users mailing list archive at Nabble.com. 
 
 
 
 
 
 View message @
 http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4103283.html
  
 To unsubscribe from Open JPA generates incorrect Union All for Date and
 Boolean Datatype, click here. 
 
 
 
   The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
 http://in.yahoo.com/
  
 

-- 
View this message in context: 
http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4130072.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.