isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grigorov <mgrigo...@apache.org>
Subject Re: Datanucleus issues
Date Tue, 01 Sep 2015 19:46:12 GMT
Hi,

On Tue, Sep 1, 2015 at 8:58 PM, Jeroen van der Wal <jeroen@stromboli.it>
wrote:

> I've never used @PrimaryKey in an Isis application, don't know if that
> works. My abstract class would typically look like this:
>

Yes, it does work.
Dan have used it in Tellmegen app.
It needs to be used with: @PersistenceCapable(identityType = IdentityType.
*APPLICATION*)


>
> @PersistenceCapable(identityType = IdentityType.DATASTORE)
> @DatastoreIdentity(column = "id", strategy = IdGeneratorStrategy.IDENTITY)
> @Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
> public abstract class AbstractParentType {
>
>     private String name;
>
>     @Column(allowsNull="true")
>     @MemberOrder(sequence = "1")
>     public String getName() {
>         return name;
>     }
>
>     public void setName(final String name) {
>         this.name = name;
>     }
>
> }
>
> Hth
>
> On 1 September 2015 at 20:44, Jeroen van der Wal <jeroen@stromboli.it>
> wrote:
>
> > If you make your abstract class public it should work fine ;-)
> >
> > Cheers,
> >
> > Jeroen
> >
> > On 1 September 2015 at 15:12, Stephen Cameron <
> steve.cameron.62@gmail.com>
> > wrote:
> >
> >> Here a two scenarios each with a Parent and Child Type, they should give
> >> the same result
> >>
> >> 1. Concrete Parent Type
> >>
> >> @PersistenceCapable()
> >> public class ConcreteParentType {
> >>
> >>     @PrimaryKey()
> >>     @Persistent(valueStrategy=IdGeneratorStrategy.INCREMENT)
> >>     private Long id;
> >>
> >>     private String name;
> >>
> >>     @Column(allowsNull="true")
> >>     @MemberOrder(sequence = "1")
> >>     public String getName() {
> >>         return name;
> >>     }
> >>
> >>     public void setName(final String name) {
> >>         this.name = name;
> >>     }
> >>
> >> }
> >>
> >> @PersistenceCapable()
> >> public class ChildTypeOfConcreteParentType extends ConcreteParentType {
> >>
> >>
> >>     private String description;
> >>
> >>     @Column(allowsNull="true")
> >>     @MemberOrder(sequence = "2")
> >>     public String getDescription() {
> >>         return description;
> >>     }
> >>
> >>     public void setDescription(final String description) {
> >>         this.description = description;
> >>     }
> >>
> >> }
> >>
> >> 2. Abstract Parent Type
> >>
> >> @PersistenceCapable()
> >> @Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
> >> abstract class AbstractParentType {
> >>
> >>     @PrimaryKey()
> >>     @Persistent(valueStrategy=IdGeneratorStrategy.INCREMENT)
> >>     private Long id;
> >>
> >>     private String name;
> >>
> >>     @Column(allowsNull="true")
> >>     @MemberOrder(sequence = "1")
> >>     public String getName() {
> >>         return name;
> >>     }
> >>
> >>     public void setName(final String name) {
> >>         this.name = name;
> >>     }
> >>
> >> }
> >>
> >> @PersistenceCapable()
> >> public class ChildTypeOfAbstractParentType extends AbstractParentType {
> >>
> >>     private String description;
> >>
> >>     @Column(allowsNull="true")
> >>     @MemberOrder(sequence = "2")
> >>     public String getDescription() {
> >>         return description;
> >>     }
> >>
> >>     public void setDescription(final String description) {
> >>         this.description = description;
> >>     }
> >>
> >> }
> >>
> >> In the seond scenario the name property doesn't appear, only the
> >> description.
> >>
> >> The DomainService class for testing these two scenarios in the viewer is
> >> this:
> >>
> >> @DomainService(nature=NatureOfService.VIEW_MENU_ONLY)
> >> @DomainServiceLayout(named = "DataNucleus", menuBar = MenuBar.PRIMARY,
> >> menuOrder = "100")
> >> public class Menu {
> >>
> >>
> >>
> >>     public ChildTypeOfConcreteParentType
> >> createChildTypeOfConcreteParentType() {
> >>         ChildTypeOfConcreteParentType childType = null;
> >>         try {
> >>             childType =
> >> container.newTransientInstance(ChildTypeOfConcreteParentType.class);
> >>             childType.setName("ChildTypeOfConcreteParentType");
> >>             childType.setDescription("something descriptive");
> >>             container.persistIfNotAlready(childType);
> >>         } catch (Exception e) {
> >>             e.printStackTrace();
> >>         }
> >>         return childType;
> >>     }
> >>
> >>     public ChildTypeOfAbstractParentType
> >> createChildTypeOfAbstractParentType() {
> >>         ChildTypeOfAbstractParentType childType = null;
> >>         try {
> >>             childType =
> >> container.newTransientInstance(ChildTypeOfAbstractParentType.class);
> >>             childType.setName("ChildTypeOfAbstractParentType");
> >>             childType.setDescription("something descriptive");
> >>             container.persistIfNotAlready(childType);
> >>         } catch (Exception e) {
> >>             e.printStackTrace();
> >>         }
> >>         return childType;
> >>     }
> >>
> >>
> >>
> >>     @javax.inject.Inject
> >>     DomainObjectContainer container;
> >>
> >> }
> >>
> >>
> >> On Tue, Sep 1, 2015 at 10:42 PM, Stephen Cameron <
> >> steve.cameron.62@gmail.com
> >> > wrote:
> >>
> >> > Hi Jeroen, just noticed this after sending second update (winge).
> >> >
> >> > I'll send a test case now.
> >> >
> >> > On Tue, Sep 1, 2015 at 10:29 PM, Jeroen van der Wal <
> >> jeroen@stromboli.it>
> >> > wrote:
> >> >
> >> >> Hi Stephen,
> >> >>
> >> >> Can you share some code to support your case?
> >> >>
> >> >> Cheers,
> >> >>
> >> >> Jeroen
> >> >>
> >> >> On 1 September 2015 at 12:39, Stephen Cameron <
> >> steve.cameron.62@gmail.com
> >> >> >
> >> >> wrote:
> >> >>
> >> >> > Hi,
> >> >> >
> >> >> > I've been trying today to find solutions to what seem to be
> >> Datanucleus
> >> >> > issues, but without much success. So rather than solve the problems
> >> >> created
> >> >> > in my refactoring of my application, which has been too hard
> frankly,
> >> >> I'm
> >> >> > trying to start afresh with some simple test cases, show these
> work,
> >> >> then
> >> >> > add more complexity till I get where I want to be.
> >> >> >
> >> >> > So, I am starting this approach and I immediately have an issue,
> but
> >> >> not a
> >> >> > Datanucleus one, I find that the value properties of an abstract
> >> parent
> >> >> > class don't appear in the Wicket viewer, whereas they do if the
> >> parent
> >> >> > class is concrete. Is this correct and if so what is the reason?
> >> >> >
> >> >> > Thanks.
> >> >> >
> >> >>
> >> >
> >> >
> >>
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message