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.getJDOExceptionForNucleusException( > NucleusJDOHelper.java:561) > > at > > org.datanucleus.api.jdo.JDOPersistenceManager.newObjectIdInstance(JDOPersist > enceManager.java:1622) > > at > > org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceMa > nager.java:1740) > > at > > org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.loadPojo( > 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.AdapterManagerDefaul > 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.getObjectA > dapter(ObjectAdapterMemento.java:288) > > at > > org.apache.isis.viewer.wicket.model.models.EntityModel.load(EntityModel.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 > > > > > >
