Hi Dan:
I have update the isis-objectstore-jdo from 1.0.0 to 1.0.1-SNAPSHOT,and the
DataNucleusObjectStore.loadPojo works fine.
There are two reasons to use "Application style Identity" for me:.
(1)、Domain Root Entity should have their Identity, and we should model the
relationship between the Root Entities with refrence to Root Entity's
Identity insteadof to Root Entity Object directly.
References:
Effective Aggregate Design:Part II Making Aggregate work togather 
Author:Vaughn Vernon
https://vaughnvernon.co/?p=139 
(2)、Domain Root Entity Identity should not depends on
JDOHelper.getObjectId(obj).

Best Regards

Alain

-----邮件原件-----
发件人: Dan Haywood [mailto:[email protected]] 
发送时间: 2013年4月11日 15:16
收件人: dev
主题: Re: DataNucleusObjectStore.loadPojo problem

Hi Alain
I suspect your JDO annotations are wrong, but before I go off on a wrong
tangent, let me ask: what is your intent for the id? should it be assigned
by the DBMS/JDO, or should it be assigned by the application?
Dan


On 11 April 2013 03:26, 张峰昌 <[email protected]> wrote:

> Hi,Dan:
>
>
>
> It seems that there are problem when to recreate an pojo with 
> DataNucleusObjectStore.loadPojo. The entity I have defined that use 
> entity itself ID which type is java.lang.Long.It’s work fine when 
> persist the entity,but will failed when load it to display in UI.
>
> The failed reason is DataNucleusObjectStore.loadPojo passed an 
> javax.jdo.identity.LongIdentity typed value into 
> org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById,but 
> datanucleus requires Long typed value.
>
>
>
>
>
> Exception statack :
>
> javax.jdo.JDOFatalInternalException: The key value passed to construct 
> a SingleFieldIdentity of type "javax.jdo.identity.LongIdentity" for 
> class "com.thingray.party.dom.person.Person" is of an incorrect type
> ("javax.jdo.identity.LongIdentity") - should be "Long".
>
>     at
>
> org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusExce
> ption(
> NucleusJDOHelper.java:561)
>
>     at
>
> org.datanucleus.api.jdo.JDOPersistenceManager.newObjectIdInstance(JDOP
> ersist
> enceManager.java:1622)
>
>     at
>
> org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersist
> enceMa
> nager.java:1740)
>
>     at
>
> org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.loa
> dPojo(
> DataNucleusObjectStore.java:390)
>
>     at
>
> org.apache.isis.objectstore.jdo.datanucleus.persistence.adaptermanager
> .DataN
> ucleusPojoRecreator.recreatePojo(DataNucleusPojoRecreator.java:38)
>
>     at
>
> org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManager
> Defaul
> t.adapterFor(AdapterManagerDefault.java:300)
>
>     at
>
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento$Type
> $2.rec
> reateAdapter(ObjectAdapterMemento.java:104)
>
>     at
>
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento$Type
> .getAd
> apter(ObjectAdapterMemento.java:170)
>
>     at
>
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento.getO
> bjectA
> dapter(ObjectAdapterMemento.java:288)
>
>     at
>
> org.apache.isis.viewer.wicket.model.models.EntityModel.load(EntityMode
> l.java
> :193)
>
>
>
> The entity I have defined:
>
>
>
>
>
> import java.util.ArrayList;
>
> import java.util.List;
>
>
>
> import javax.jdo.annotations.IdGeneratorStrategy;
>
> import javax.jdo.annotations.IdentityType;
>
> import javax.jdo.annotations.Inheritance;
>
> import javax.jdo.annotations.InheritanceStrategy;
>
> import javax.jdo.annotations.PersistenceCapable;
>
> import javax.jdo.annotations.Persistent;
>
> import javax.jdo.annotations.PrimaryKey;
>
> import javax.jdo.annotations.Queries;
>
> import javax.jdo.annotations.Query;
>
> import javax.jdo.annotations.Version;
>
> import javax.jdo.annotations.VersionStrategy;
>
>
>
> import org.apache.isis.applib.annotation.Hidden;
>
> import org.apache.isis.applib.annotation.MemberOrder;
>
> import org.apache.isis.applib.annotation.Named;
>
> import org.apache.isis.applib.annotation.Optional;
>
> import org.apache.isis.applib.annotation.Title;
>
> import org.apache.isis.applib.annotation.When;
>
> import org.apache.isis.applib.value.Date;
>
>
>
> import com.thingray.party.dom.Party;
>
> import com.thingray.party.dom.person.value.GenderType;
>
> import com.thingray.party.dom.role.value.PartyRoleType;
>
> /**
>
> *
>
>  * 人。
>
> * @author alain
>
> * @version $Revision 1.0$ 2012-10-15
>
> * @since 1.0
>
> * @author (lastest modification by $Author$)
>
> */
>
> @PersistenceCapable(table="PA_PERSON")
>
> @Queries({
>
>          @Query(name = "person_find_by_name",
>
>                             value = "  SELECT FROM 
> com.thingray.party.dom.person.Person " +
>
>                                                "       WHERE
> firstName.indexOf(:personName)>=0 " +
>
>                                                "       ORDER BY
> firstName"),
>
>          @Query(name = "person_find_by_login_account",
>
>                             value = "  SELECT FROM 
> com.thingray.party.dom.person.Person " +
>
>                                                "       WHERE
> loginAccount==:loginAccount")
>
> })
>
> @Inheritance(strategy=InheritanceStrategy.NEW_TABLE)
>
> @Version(strategy=VersionStrategy.VERSION_NUMBER,column="VERSION")
>
> public class Person {
>
>          // {{ PartyID (参与方标识)
>
>
>
>          private Long partyID;
>
>
>
>          @MemberOrder(sequence = "1")
>
>          @Hidden(when=When.UNTIL_PERSISTED)
>
>          @Named("参与方标识")
>
>          @Persistent(primaryKey = "true", valueStrategy =
> IdGeneratorStrategy.NATIVE)
>
>          public Long getPartyID() {
>
>                    return partyID;
>
>          }
>
>
>
>          public void setPartyID(final Long partyID) {
>
>                    this.partyID = partyID;
>
>          }
>
>
>
>          // }}
>
>
>
>          // {{ LastName (姓)
>
>          private String lastName;
>
>
>
>          @MemberOrder(sequence = "1")
>
>          @Named("姓")
>
>          @Title(sequence="1")
>
>          public String getLastName() {
>
>                    return lastName;
>
>          }
>
>
>
>          public void setLastName(final String lastName) {
>
>                    this.lastName = lastName;
>
>          }
>
>          // }}
>
>
>
>          // {{ FirstName (名)
>
>          private String firstName;
>
>
>
>          @MemberOrder(sequence = "2")
>
>          @Named("名")
>
>          @Title(sequence="2")
>
>          public String getFirstName() {
>
>                    return firstName;
>
>          }
>
>
>
>          public void setFirstName(final String firstName) {
>
>                    this.firstName = firstName;
>
>          }
>
>          // }}
>
> }
>
>
>
>
>
> Alain
>
>
>
>
>
>

Reply via email to