Thanks Dan,

I saw the OIDMarshallaer code and used the other separated character than 
reserved characters for ISIS. Its working fine.

But thing is that we have to restrict the PK fields not to have this separated 
character in its values. I hope JDO in future fixes this limitation may be by 
using similar EmbeddedId technique from JPA where we don't have bother about 
joining/splitting PK fields

BR
Ranganath Varma

-----Original Message-----
From: Dan Haywood [mailto:[email protected]]
Sent: Thursday, January 09, 2014 8:24 PM
To: users
Subject: Re: Application Identity: Issue with Compsite PK class with multiple 
attributes.

Hi Varma,

There are, unfortunately, rather a lot of reserved characters that Isis has for 
its encoding of OIDs, as you can see from the source [1].  (I find that regex 
difficult to read, but the source code helps untangle the structure).

In addition, as you've discovered, the '_' (underscore) character is also used 
to distinguish between the PK class and its value [2].  I don't think that's 
actually an issue here, though... your issue is in the parsing of the 
identifier string.

Nevertheless, notwithstanding the limitations that Isis puts in terms of what 
you can have in your PK class' toString method, I actually think the problem 
here is a bug in your code.  If the org or location strings can contain a '_' 
(which you say that they can), then you can't also use '_' to separate those 
two components.

You were definitely on the right lines trying to use some other character (eg : 
or ::), but (per [1]) Isis prevents you from doing that.

What we need to do is to use some other separator character, that isn't any
of:

        private static final String SEPARATOR = ":";
        private static final String SEPARATOR_NESTING = "~";
        private static final String SEPARATOR_COLLECTION = "$";
        private static final String SEPARATOR_VERSION = "^";


My suggestion is that you try using a simple '.' (period) instead.  Thus, the 
toString() would be something like "ORG_FILTER_TEST.ATL"

Let us know how you get on.

Dan



[1]
https://github.com/apache/isis/blob/prepare/isis-1.3.0-RC1/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/OidMarshaller.java#L97
[2]
https://github.com/apache/isis/blob/prepare/isis-1.3.0-RC1/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java#L44





On 8 January 2014 21:38, GESCONSULTOR - Óscar Bou <[email protected]>wrote:

>
>
> This one seems more related to the OID Marshaller than with JDO.
>
> Perhaps Dan can give some light on it.
>
>
> El 03/01/2014, a las 10:14, [email protected] escribió:
>
> >
> > I am using ISIS 1.3.0 with JDO 3.0.1, Data Nucleus 3.2.4
> >
> >
> > Using JDO Application Identity strategy, I have a composite PK class
> with two attributes(PK fields of type String).
> >
> > As per the JDO specifications, PK class has overridden the following
> methods:
> > hascode, equals and toString.
> >
> > And it has Constructor which takes String parameter.
> >
> > Problem is that for some Entities OID is not found if any of the PK
> fields has the same character which is used to join in the toString
> method
> > For example: Consider the below PK class:
> > public class OmGeoLocationPK implements java.io.Serializable {
> >
> >      public String locationId;
> >      public String orgId;
> > public OmGeoLocationPK() {
> >      }
> >
> >      public OmGeoLocationPK(String locationId, String orgId) {
> >            this.locationId = locationId;
> >            this.orgId = orgId;
> >      }
> >      public OmGeoLocationPK(String key){
> >            StringTokenizer token = new StringTokenizer(key, "_");
> >            this.locationId = token.nextToken();
> >            this.orgId = token.nextToken();
> >
> >      }
> >
> >      public String getLocationId() {
> >            return this.locationId;
> >      }
> >
> >      public void setLocationId(String locationId) {
> >            this.locationId = locationId;
> >      }
> >
> >      public String getOrgId() {
> >            return this.orgId;
> >      }
> >
> >      public void setOrgId(String orgId) {
> >            this.orgId = orgId;
> >      }
> >
> >      public String toString() {
> >            return "" + locationId + "_" + this.orgId;
> >      }
> >
> >      @Override
> >      public int hashCode() {
> >            final int prime = 31;
> >            int result = 1;
> >            result = prime * result
> >                        + ((locationId == null) ? 0 :
> locationId.hashCode());
> >            result = prime * result + ((orgId == null) ? 0 :
> orgId.hashCode());
> >            return result;
> >      }
> >
> >      @Override
> >      public boolean equals(Object obj) {
> >            if (this == obj)
> >                  return true;
> >            if (obj == null)
> >                  return false;
> >            if (getClass() != obj.getClass())
> >                  return false;
> >            OmGeoLocationPK other = (OmGeoLocationPK) obj;
> >            if (locationId == null) {
> >                  if (other.locationId != null)
> >                        return false;
> >            } else if (!locationId.equals(other.locationId))
> >                  return false;
> >            if (orgId == null) {
> >                  if (other.orgId != null)
> >                        return false;
> >            } else if (!orgId.equals(other.orgId))
> >                  return false;
> >            return true;
> >      }
> >
> >
> >
> > }
> >
> > Here in the toString method "_" character used to join two PK fields
> (locationId and orgId).
> >
> > So, if locationId or orgId has the chracter "_" in its S tring
> > value, Splitting with StringTokenizer is not evaluating the
> correct PK feilds values and it throws the following exception:
> >
> >
> > Caused by:
> org.apache.isis.core.runtime.persistence.ObjectNotFoundException:
> Object not found in store with oid
> OmSite:com.wipro.wess.OmGeoLocationPK_ORG_FILTER_TEST_ATL
> >      at
> org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManager
> Default.adapterFor(AdapterManagerDefault.java:308)
> >      at
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento$Type
> $2.recreateAdapter(ObjectAdapterMemento.java:112)
> >      at
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento$Type
> .getAdapter(ObjectAdapterMemento.java:183)
> >      at
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento.getO
> bjectAdapter(ObjectAdapterMemento.java:301)
> >      at
> org.apache.isis.viewer.wicket.ui.components.widgets.entitylink.EntityL
> inkSelect2Panel.onSelected(EntityLinkSelect2Panel.java:328)
> >      at
> org.apache.isis.viewer.wicket.ui.components.widgets.entitylink.EntityL
> inkSelect2Panel.convertInput(EntityLinkSelect2Panel.java:156)
> >      at
> org.apache.wicket.markup.html.form.FormComponent.validate(FormComponen
> t.java:1137)
> >      at
> org.apache.wicket.markup.html.form.Form$16.validate(Form.java:1862)
> >      at
> org.apache.wicket.markup.html.form.Form$ValidationVisitor.component(Fo
> rm.java:177)
> >      at
> org.apache.wicket.markup.html.form.Form$ValidationVisitor.component(Fo
> rm.java:161)
> >      at
> org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:2
> 74)
> >      at
> org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:2
> 62)
> >      at
> org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:2
> 62)
> >      at
> org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:2
> 62)
> >      at
> org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:2
> 62)
> >      at
> org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:2
> 62)
> >      at
> org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:2
> 62)
> >      at
> org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:2
> 62)
> >      at
> org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:2
> 62)
> >      at
> org.apache.wicket.util.visit.Visits.visitPostOrder(Visits.java:245)
> >      at
> org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPo
> stOrder(FormComponent.java:389)
> >      at
> org.apache.wicket.markup.html.form.Form.visitFormComponentsPostOrder(F
> orm.java:1093)
> >      at
> org.apache.wicket.markup.html.form.Form.validateComponents(Form.java:1
> 854)
> >      at org.apache.wicket.markup.html.form.Form.validate(Form.java:1819)
> >      at org.apache.wicket.markup.html.form.Form.process(Form.java:894)
> >      at
> org.apache.isis.viewer.wicket.ui.panels.FormAbstract.process(FormAbstr
> act.java:118)
> >      at
> org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:771)
> >      at
> org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:704)
> >      ... 41 more
> > Caused by: javax.jdo.JDOObjectNotFoundException: No such database
> > row FailedObject:ORG_FILTER
> > NestedThrowables:
> > org.datanucleus.exceptions.NucleusObjectNotFoundException: No such
> database row
> >      at
> org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusExce
> ption(NucleusJDOHelper.java:475)
> >      at
> org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersist
> enceManager.java:1727)
> >      at
> org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersist
> enceManager.java:1740)
> >      at
> org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.loa
> dPojo(DataNucleusObjectStore.java:404)
> >      at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.adaptermanager
> .DataNucleusPojoRecreator.recreatePojo(DataNucleusPojoRecreator.java:3
> 8)
> >      at
> org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManager
> Default.adapterFor(AdapterManagerDefault.java:305)
> >      ... 68 more
> >
> > Actually, locationId is: ORG_FILTER_TEST and orgId is : ATL.
> > But after tokenizing with "_" OID evaluated as ORG_FILTER as
> > locationId has "_" in it.
> >
> > So I tried with other characters which would not be expected in
> > those
> fields like ":" (colon), "::"(double colon). But these characters are
> not supported. And I got the exception coming from OIDMarshaller of
> ISIS
> >
> >
> >
> >       at
> org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactor
> y.java:171)
> >       ... 41 more
> > Caused by: java.lang.IllegalArgumentException: Could not parse OID
> 'OmGeoLocation:com.wipro.wess.OmGeoLocationPK_EC3::WPL'; should match
> pattern:
> ^((([!*])?([^:~$\^#]+):([^:~$\^#]+))((~[^:~$\^#]+:[^:~$\^#]+)*))([$][^
> :~$\^#]+)?([\^](\d+):([^:~$\^#]+)?:(\d+)?)?$
> >       at
> org.apache.isis.core.metamodel.adapter.oid.OidMarshaller.unmarshal(Oid
> Marshaller.java:146)
> >       at
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento$Type
> $2.recreateAdapter(ObjectAdapterMemento.java:110)
> >       at
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento$Type
> .getAdapter(ObjectAdapterMemento.java:183)
> >       at
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento.getO
> bjectAdapter(ObjectAdapterMemento.java:301)
> >       at
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento.capt
> ureTitleHintIfPossible(ObjectAdapterMemento.java:279)
> >       at
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento.<ini
> t>(ObjectAdapterMemento.java:239)
> >       at
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento.crea
> teOrNull(ObjectAdapterMemento.java:58)
> >       at
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento$Func
> tions$6.apply(ObjectAdapterMemento.java:416)
> >       at
> org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento$Func
> tions$6.apply(ObjectAdapterMemento.java:412)
> >       at
> com.google.common.collect.Iterators$8.transform(Iterators.java:794)
> >       at
> com.google.common.collect.TransformedIterator.next(TransformedIterator
> .java:48)
> >       at com.google.common.collect.Iterators.addAll(Iterators.java:357)
> >       at com.google.common.collect.Lists.newArrayList(Lists.java:146)
> >       at com.google.common.collect.Lists.newArrayList(Lists.java:128)
> >       at
> org.apache.isis.viewer.wicket.model.models.EntityCollectionModel.asMem
> entoList(EntityCollectionModel.java:156)
> >       at
> org.apache.isis.viewer.wicket.model.models.EntityCollectionModel.creat
> eStandalone(EntityCollectionModel.java:145)
> >       at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel$Result
> Type$2.addOrReplaceCollectionResultsPanel(ActionPanel.java:392)
> >       at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel$Result
> Type$2.addResults(ActionPanel.java:388)
> >       at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.execut
> eActionOnTargetAndProcessResults(ActionPanel.java:213)
> >       at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.execut
> eActionAndProcessResults(ActionPanel.java:165)
> >       at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.buildG
> ui(ActionPanel.java:102)
> >       at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.<init>
> (ActionPanel.java:95)
> >       at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanelFactory
> .createComponent(ActionPanelFactory.java:49)
> >       at
> org.apache.isis.viewer.wicket.ui.ComponentFactoryAbstract.createCompon
> ent(ComponentFactoryAbstract.java:82)
> >       at
> org.apache.isis.viewer.wicket.viewer.registries.components.ComponentFa
> ctoryRegistryDefault.createComponent(ComponentFactoryRegistryDefault.j
> ava:120)
> >       at
> org.apache.isis.viewer.wicket.viewer.registries.components.ComponentFa
> ctoryRegistryDefault.addOrReplaceComponent(ComponentFactoryRegistryDef
> ault.java:105)
> >       at
> org.apache.isis.viewer.wicket.ui.pages.PageAbstract.addComponent(PageA
> bstract.java:281)
> >       at
> org.apache.isis.viewer.wicket.ui.pages.PageAbstract.addChildComponents
> (PageAbstract.java:276)
> >       at
> org.apache.isis.viewer.wicket.ui.pages.action.ActionPage.<init>(Action
> Page.java:54)
> >       ... 46 more
> > Please help on this issue.
> >
> > BR
> > Ranganath Varma
> >
> >
> > The information contained in this electronic message and any
> > attachments
> to this message are intended for the exclusive use of the addressee(s)
> and may contain proprietary, confidential or privileged information.
> If you are not the intended recipient, you should not disseminate,
> distribute or copy this e-mail. Please notify the sender immediately
> and destroy all copies of this message and any attachments.
> >
> > WARNING: Computer viruses can be transmitted via email. The
> > recipient
> should check this email and any attachments for the presence of viruses.
> The company accepts no liability for any damage caused by any virus
> transmitted by this email.
> >
> > www.wipro.com
>
>

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com

Reply via email to