Re: state-of-the art attribute initialization in persistent pojos?

2007-04-12 Thread Thomas Risberg
I thought the no-arg constructor had to be public or protected - see
2.1 Requirements on the Entity Class section where this is mentioned. 
If that's not the case so much better, but I have been adding a
protected constructor in my entities.

Cheers,
Thomas


Craig L Russell wrote:
 Hi Hans,

 On Apr 12, 2007, at 8:43 AM, Hans J. Prueller wrote:

 hi,
 as you know I am switching from EJB2.1 CMP to JPA (OpenJPA). I'd like
 to know the preferred way to perform attribute initialisation of
 newly created entity instances, e.g. we initialized our EJB2.1 CMP
 entity beans with

 ejbCreate(String cid, Integer someOtherValue)
 {
 setabc();
 setdef();
 }

 //and ejbPostCreate optionally

 as far as I know, the JPA spec requires a no-arg constructor - so
 when providing a constructor with the same args that we have used in
 ejbCreate before, we cannot ensure that some developer calls the
 no-arg constructor by default.

 The no-arg constructor can be private. The reason it's required is so
 the implementation doesn't have to guess what the right values are for
 final variables. But there's no requirement to make this constructor
 available to your applications.

 is there any other-more elegant way to force new entity instance
 initialization?

 There's no requirement for an ejbCreate and a separate ejbPostCreate
 for relationships. So you are really free to do whatever you like for
 the application contract. Have as many constructors as you like and
 put whatever initialization into them.

 Just don't initialize the values of generated fields...

 Craig

 regards,

 HANS

 ===
 virtually hanzz...

  http://hanzz.zapto.org http://hanzz.zapto.org (personal)
  http://www.cse.dmu.ac.uk/~hansp http://www.cse.dmu.ac.uk/~hansp
 (research)

 Craig Russell
 Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
 408 276-5638 mailto:[EMAIL PROTECTED]
 P.S. A good JDO? O, Gasp!




[jira] Commented: (OPENJPA-40) Testing OpenJPA and Spring integration fails

2006-09-11 Thread Thomas Risberg (JIRA)
[ 
http://issues.apache.org/jira/browse/OPENJPA-40?page=comments#action_12433878 ] 

Thomas Risberg commented on OPENJPA-40:
---

I made the changes you suggested and I can now run the test relying only on 
annotations.  As soon as I involve an orm.xml in combination with the 
annotations I see errors - see OPENJPA-42 for specific error I get.  Once those 
errors are resoved I'll come back to this issue to retest it.

Thanks. 

 Testing OpenJPA and Spring integration fails
 

 Key: OPENJPA-40
 URL: http://issues.apache.org/jira/browse/OPENJPA-40
 Project: OpenJPA
  Issue Type: Test
 Environment:  [java] os.name: Mac OS X
  [java] os.version: 10.4.7
  [java] os.arch: ppc
  [java] java.version: 1.5.0_06
  [java] java.vendor: Apple Computer, Inc.
 OpenJPA built from SVN (revision 440460)
Reporter: Thomas Risberg
 Assigned To: Marc Prud'hommeaux
 Attachments: OpenJpaLoadTimeWeaver.java, testOpenJpa.zip


 I have attached a test case including jar files and a build script.  
 src/repository-config.xml contains the Spring configuration and switching to 
 the TopLink vendor adapter does not show any issues - the test runs fine.  
 Using the current OpenJPA vendor adapter (Spring sandbox source is included 
 in src directory) causes this failure:
 First the version info:
 samoa:~/Projects/testOpenJpa trisberg$ ant openjpa-version
 Buildfile: build.xml
 openjpa-version:
  [java] OpenJPA 0.9.0-incubating-SNAPSHOT
  [java] version id: 0.9.0-incubating-SNAPSHOT-r0
  [java] revision: 0
  [java] os.name: Mac OS X
  [java] os.version: 10.4.7
  [java] os.arch: ppc
  [java] java.version: 1.5.0_06
  [java] java.vendor: Apple Computer, Inc.
  [java] java.class.path:
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/commons-collections-3.2.jar
  [java] /Users/trisberg/Projects/testOpenJpa/lib/commons-lang-2.1.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/commons-logging-1.0.4.jar
  [java] /Users/trisberg/Projects/testOpenJpa/lib/commons-pool-1.3.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/geronimo-j2ee-connector_1.5_spec-1.0.1.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/geronimo-jta_1.0.1B_spec-1.0.1.jar
  [java] /Users/trisberg/Projects/testOpenJpa/lib/hsqldb.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/openjpa-jdbc-0.9.0-incubating-SNAPSHOT.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/openjpa-jdbc-5-0.9.0-incubating-SNAPSHOT.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/openjpa-kernel-0.9.0-incubating-SNAPSHOT.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/openjpa-kernel-5-0.9.0-incubating-SNAPSHOT.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/openjpa-lib-0.9.0-incubating-SNAPSHOT.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/openjpa-persistence-0.9.0-incubating-SNAPSHOT.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/openjpa-persistence-jdbc-0.9.0-incubating-SNAPSHOT.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/openjpa-xmlstore-0.9.0-incubating-SNAPSHOT.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/persistence-api-1.0.jar
  [java] /Users/trisberg/Projects/testOpenJpa/lib/serp-1.11.0.jar
  [java] /Users/trisberg/Projects/testOpenJpa/lib/spring-jpa.jar
  [java] /Users/trisberg/Projects/testOpenJpa/lib/spring-sandbox.jar
  [java] /Users/trisberg/Projects/testOpenJpa/lib/spring.jar
  [java] 
 /Users/trisberg/Projects/testOpenJpa/lib/toplink-essentials.jar
  [java] /Users/trisberg/Projects/testOpenJpa/classes
  [java] 
 /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/.compatibility/14compatibility.jar
  [java] user.dir: /Users/trisberg/Projects/testOpenJpa
 BUILD SUCCESSFUL
 Total time: 3 seconds
 And now the runtime error:
 samoa:~/Projects/testOpenJpa trisberg$ ant run-test
 Buildfile: build.xml
 run-test:
  [java] TestApp!
  [java] Sep 6, 2006 1:11:02 PM org.springframework.core.CollectionFactory 
 clinit
  [java] INFO: JDK 1.4+ collections available
  [java] Sep 6, 2006 1:11:02 PM org.springframework.core.CollectionFactory 
 clinit
  [java] INFO: Commons Collections 3.x available
  [java] Sep 6, 2006 1:11:02 PM 
 org.springframework.beans.factory.xml.XmlBeanDefinitionReader 
 loadBeanDefinitions
  [java] INFO: Loading XML bean definitions from class path resource 
 [repository-config.xml]
  [java] Sep 6, 2006 1:11:03 PM 
 org.springframework.context.support.AbstractRefreshableApplicationContext 
 refreshBeanFactory
  [java] INFO: Bean factory for application context

[jira] Updated: (OPENJPA-42) Simple orm.xml file causes exception (NPE)

2006-09-11 Thread Thomas Risberg (JIRA)
 [ http://issues.apache.org/jira/browse/OPENJPA-42?page=all ]

Thomas Risberg updated OPENJPA-42:
--

Attachment: OPENJPA-42.zip

Marc,

I saw your fix for the circular reference and I don't see the error message 
right now after checking out the latest (now at rev. 442412). I'm getting an 
error building, but the jars seem to be created anyway.  This is the last part 
of the build messages:

[INFO] [jar:jar]
[INFO] Building jar: 
/Users/trisberg/Projects/OpenJPA/openjpa-all/target/openjpa-all-0.9.0-incubating-SNAPSHOT.jar
[INFO] 

[INFO] Building OpenJPA Distribution
[INFO]task-segment: [clean, package]
[INFO] 

[INFO] 
[ERROR] BUILD ERROR
[INFO] 
[INFO] 'attached' was specified in an execution, but not found in the plugin
[INFO] 
[INFO] For more information, run Maven with the -e switch
[INFO] 
[INFO] Total time: 2 minutes 5 seconds
[INFO] Finished at: Mon Sep 11 21:57:00 EDT 2006
[INFO] Final Memory: 16M/59M
[INFO] 

Anyway, I still get an exception executing my test - see attached zip file.  Is 
this related to OPENJPA-44 since I do use the metadata-complete attribute? 

Exception in thread main 4|true|0.9.0-incubating-SNAPSHOT 
org.apache.openjpa.persistence.ArgumentException: Could not locate metadata for 
the class using alias Manager. Registered alias mappings: {Manager=null}
at 
org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:362)
at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:166)
at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:144)
at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:213)
at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:183)
at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:176)
at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$500(JPQLExpressionBuilder.java:63)
at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:1666)
at 
org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:52)
at 
org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:145)
at 
org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:599)
at 
org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:581)
at 
org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:608)
at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1421)
at 
org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:120)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:205)
at 
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:254)
at springdeveloper.MyTest.runQuery(MyTest.java:13)
at springdeveloper.TestApp.run(TestApp.java:53)
at springdeveloper.TestApp.main(TestApp.java:22)


 Simple orm.xml file causes exception (NPE)
 --

 Key: OPENJPA-42
 URL: http://issues.apache.org/jira/browse/OPENJPA-42
 Project: OpenJPA
  Issue Type: Bug
 Environment: Mac OS X
 Java 5 SE
 Resource Local
 OpenJPA build from SVN  rev. 441247
Reporter: Thomas Risberg
 Attachments: OPENJPA-42.zip, plainJpa.zip


 This simple orm.xml file causes a NPE - 
 ?xml version=1.0 encoding=UTF-8?
 entity-mappings xmlns=http://java.sun.com/xml/ns/persistence/orm;
 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
 xsi:schemaLocation=http://java.sun.com/xml/ns/persistence/orm 
 http://java.sun.com/xml/ns/persistence/orm_1_0.xsd;
 version=1.0
   packagespringdeveloper.domain/package
   entity class=Client metadata-complete=false access=FIELD/entity
   entity class=Manager metadata-complete=false access=FIELD
 attribute-override name=description
   column name=DESCR length=2000/
 /attribute-override
   /entity
 /entity-mappings
 I have attached a test case - plainJpa.zip
 Same code runs fine with the RI.
 This is the output from my run:
 /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/bin/java

[jira] Created: (OPENJPA-42) Simple orm.xml file causes exception (NPE)

2006-09-07 Thread Thomas Risberg (JIRA)
Simple orm.xml file causes exception (NPE)
--

 Key: OPENJPA-42
 URL: http://issues.apache.org/jira/browse/OPENJPA-42
 Project: OpenJPA
  Issue Type: Bug
 Environment: Mac OS X
Java 5 SE
Resource Local

OpenJPA build from SVN  rev. 441247
Reporter: Thomas Risberg
 Attachments: plainJpa.zip

This simple orm.xml file causes a NPE - 

?xml version=1.0 encoding=UTF-8?

entity-mappings xmlns=http://java.sun.com/xml/ns/persistence/orm;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://java.sun.com/xml/ns/persistence/orm 
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd;
version=1.0

  packagespringdeveloper.domain/package

  entity class=Client metadata-complete=false access=FIELD/entity
  entity class=Manager metadata-complete=false access=FIELD
attribute-override name=description
  column name=DESCR length=2000/
/attribute-override
  /entity

/entity-mappings

I have attached a test case - plainJpa.zip

Same code runs fine with the RI.

This is the output from my run:

/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/bin/java 
-Dfile.encoding=MacRoman -classpath 
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/deploy.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/dt.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/jce.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/plugin.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/sa-jdi.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/charsets.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/jconsole.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/jsse.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/laf.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/ui.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/apple_provider.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/dnsns.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/localedata.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/sunjce_provider.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/sunpkcs11.jar:/Users/trisberg/Projects/plainJpa/classes:/Users/trisberg/Projects/plainJpa/lib/openjpa-jdbc-0.9.0-incubating-SNAPSHOT.jar:/Users/trisberg/Projects/plainJpa/lib/openjpa-persistence-0.9.0-incubating-SNAPSHOT.jar:/Users/trisberg/Projects/plainJpa/lib/openjpa-lib-0.9.0-incubating-SNAPSHOT.jar:/Users/trisberg/Projects/plainJpa/lib/openjpa-kernel-5-0.9.0-incubating-SNAPSHOT.jar:/Users/trisberg/Projects/plainJpa/lib/commons-collections-3.2.jar:/Users/trisberg/Projects/plainJpa/lib/geronimo-jta_1.0.1B_spec-1.0.1.jar:/Users/trisberg/Projects/plainJpa/lib/geronimo-j2ee-connector_1.5_spec-1.0.1.jar:/Users/trisberg/Projects/plainJpa/lib/commons-pool-1.3.jar:/Users/trisberg/Projects/plainJpa/lib/serp-1.11.0.jar:/Users/trisberg/Projects/plainJpa/lib/hsqldb.jar:/Users/trisberg/Projects/plainJpa/lib/persistence-api-1.0.jar:/Users/trisberg/Projects/plainJpa/lib/commons-logging-1.0.4.jar:/Users/trisberg/Projects/plainJpa/lib/commons-dbcp-1.2.1.jar:/Users/trisberg/Projects/plainJpa/lib/openjpa-persistence-jdbc-0.9.0-incubating-SNAPSHOT.jar:/Users/trisberg/Projects/plainJpa/lib/commons-lang-2.1.jar:/Users/trisberg/Projects/plainJpa/lib/openjpa-kernel-0.9.0-incubating-SNAPSHOT.jar:/Users/trisberg/Projects/plainJpa/lib/openjpa-jdbc-5-0.9.0-incubating-SNAPSHOT.jar
 springdeveloper.TestApp
OPenJPAVersion:
OpenJPA 0.9.0-incubating-SNAPSHOT
version id: 0.9.0-incubating-SNAPSHOT-r0
revision: 0

os.name: Mac OS X
os.version: 10.4.7
os.arch: ppc

java.version: 1.5.0_06
java.vendor: Apple Computer, Inc.

java.class.path:

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/deploy.jar

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/dt.jar

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/jce.jar

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/plugin.jar

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/sa-jdi.jar

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/charsets.jar

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/classes.jar

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/jconsole.jar

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/jsse.jar

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/laf.jar

/System/Library/Frameworks/JavaVM.framework/Versions

Re: bootstrapping OpenJPA with Spring

2006-08-31 Thread Thomas Risberg
Marc,

The integration code is now in the sandbox.  Haven't tried this yet, but
Costin indicated that he ran into a few issues -
http://forum.springframework.org/showpost.php?p=75333postcount=7

Thomas


Marc Logemann wrote:
 Hi,

 sounds good. At least its no problem to get a jar as far as i can see.
 Compiling/Building works with some expected maven hiccups.

 -- 
 regards
 Marc Logemann
 [blog] http://www.logemann.org
 [busn] http://www.logentis.de


 Am 28.08.2006 um 19:15 schrieb Thomas Risberg:

 Marc,

 It's coming - see this forum post
 http://forum.springframework.org/showthread.php?p=74659#post74659

 Thomas Risberg


 [EMAIL PROTECTED] wrote:
 Hi,

 i wonder why there is no OpenJPA-JpaVendorAdapter in the Spring 2.0
 distro. As you can see at
 http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/orm/jpa/vendor/package-summary.html