You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by mi...@xup.nl on 2012/09/18 14:35:50 UTC

Stuck on using JDO object store.

Hi folks,

I am sort of stuck when using the JDO object store. I basically have 2  
issues that I need to resolve.

Issue 1: UUID and DateTime are not stored
------------------------------------------
When creating a new Report (without any statuses) the timestamp and  
uuid are automatically generated. So on initial create there are no  
edit fields for these 2 properties as expected. Pressing 'Ok' stores  
the information in the database and shows the details view where both  
fields are shown with proper data.
However when retrieving the same record from the database both these  
fields are shown empty.

What could have caused this behaviour (where do I have to look)?
Do I have to do something special to get these values to be stored as well?

Issue 2: Statusses are not attached to report
---------------------------------------------
I have troubles adding a status to the report. When looking in the  
database I find tables for both Report and Status. But I can not find  
any relation between both tables.

I am probably overlooking something but I can't figure out what?

Model:
------
class Report {
   UUID uuid;
   DateTime timestamp        // Isis DateTime
   String reporter;
   String reason;
   List<Status> statuses;
}

class Status {
   DateTime timestamp        // Isis DateTime
   String remark;
   Integer statusValue;
}

- For UUID I created a ValueSemanticsProvider. The value is shown  
properly on screen.
- The ReportRepository contains methods for creating a new Report and  
searching for reports.
- Statuses are created through Report.addStatus() looking something like this:

   public void addStatus( @Named("Partij") Integer partij,
       @Named("Duider") String duider,
       @Named("Status") Integer status,
       @Named("Toelichting") String toelichting) {
     final Status statusObject = newTransientInstance(Status.class);
     statusObject.set...
     statuses.add(statusObject);   // Shouldn't 'this' be saved as well?
     persist(statusObject);
   }


Environment:
------------
0.3.1-SNAPSHOT
JDO objectstore on postgresql
Html viewer

Any help is greatly appreciated.

Regards,

Minto


Re: Stuck on using JDO object store.

Posted by Kevin Meyer <ke...@kmz.co.za>.
The issue with the SQL-OS is that each data type needs its own custom "valuie mapper" that handles read/writes from/to the database tables.

The native Joda classes would need to be implemented before they can be persisted...

Regards,
Kevin

Jeroen van der Wal <je...@stromboli.it> wrote:

>First of all there's no intention to break other components by using
>Joda
>natively. We've added support for Joda in the JDO object store already
>and
>I recommend that other object stores and viewers will start supporting
>Joda
>types too, it shouldn't be hard to accomplish that. Marking the applib
>date/time classes being deprecated will hint developers to use Joda
>over
>applib but will not break anything. It's up to the community to do a
>vote
>on the final removal of the classes but there's no rush to do that.
>
>Your quick fix to expose the underlying Joda classes would IMHO make
>things
>more complicated than it should be. One of the drivers to move to Joda
>is
>that in the current application we're building we have to do a lot of
>time
>and date based calculations and Joda excels in that.
>
>A little refactoring should not stop the improvement of the framework
>but
>perhaps I'm missing some more relevant.
>
>Kind Regards,
>
>Jeroen
>
>On Tue, Sep 18, 2012 at 7:05 PM, Kevin Meyer - KMZ <ke...@kmz.co.za>
>wrote:
>
>> An immediate quick fix would be to provide a getter on the applib
>date
>> classes that exposes the underlying Joda class... then you could get
>> the full access you want, without affecting any other component (e.g.
>> the Isis sql object store ;-) )
>>
>> Regards,
>> Kevin
>>
>> On 18 Sep 2012 at 16:50, Jeroen van der Wal wrote:
>>
>> > The reason that I use Joda is because I want to access it full
>> capabilities.
>> >
>> > +1 to mark the applib date/times as deprecated and leave it around
>for a
>> > while. I'm volunteering to do some refactoring of Isis.
>> >
>> > Regards,
>> >
>> > Jeroen
>> >
>> >
>> >
>> >
>> > On Tue, Sep 18, 2012 at 4:20 PM, Dan Haywood
>> > <da...@haywood-associates.co.uk>wrote:
>> >
>> > > I wonder if we should just get rid of the Isis applib date/times?
>>  It's not
>> > > like our implementation is in any way superior to Joda (rather:
>it is
>> > > substantially inferior).
>> > >
>> > >
>> > >
>> > > On 18 September 2012 14:54, Kevin Meyer - KMZ <ke...@kmz.co.za>
>wrote:
>> > >
>> > > > Hi all,
>> > > >
>> > > > This probably does not have any direct bearing on this
>discussion,
>> but
>> > > > I have converted all Isis date / time variables to (at their
>core)
>> use
>> > > > Joda time instead of Java time classes... the core Joda time
>property
>> > > > might not be exposed, though.
>> > > >
>> > > > Regards,
>> > > > Kevin
>> > > >
>> > > > On 18 Sep 2012 at 15:38, Jeroen van der Wal wrote:
>> > > >
>> > > > > Hi Minto,
>> > > > >
>> > > > > 1. UUID is not persisted by default but will be if you mark
>it with
>> > > > > @Persistent. Don't know from the top of my head if that's
>also the
>> case
>> > > > for
>> > > > > the applib.DateTime. As an alternative you can use
>> > > org.joda.time.DateTime
>> > > > > (which also must be annotated with @Persistent). See the
>> Datanucleus
>> > > > > documentation on Java types[1] for more information.
>> > > > >
>> > > > > 2. Collections should be marked with
>> > > > > @Persistent(mappedBy="<parent class>") for a 1-N
>relationship. Add
>> an
>> > > > > additional @Join to create a separate join table. Again,
>> Datanucleus
>> > > > > provides loads of documentation on this topic [2].
>> > > > >
>> > > > > Hope this helps.
>> > > > >
>> > > > > Jeroen
>> > > > >
>> > > > > [1]
>http://www.datanucleus.org/products/datanucleus/jdo/types.html
>> > > > > [2]
>> > > > >
>> > > >
>> > >
>>
>http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_many_set.html
>> > > > >
>> > > > >
>> > > > >
>> > > > >
>> > > > >
>> > > > > --
>> > > > > Jeroen van der Wal
>> > > > > Stromboli b.v.
>> > > > > +31 655 874050
>>
>>

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Re: Stuck on using JDO object store.

Posted by Jeroen van der Wal <je...@stromboli.it>.
First of all there's no intention to break other components by using Joda
natively. We've added support for Joda in the JDO object store already and
I recommend that other object stores and viewers will start supporting Joda
types too, it shouldn't be hard to accomplish that. Marking the applib
date/time classes being deprecated will hint developers to use Joda over
applib but will not break anything. It's up to the community to do a vote
on the final removal of the classes but there's no rush to do that.

Your quick fix to expose the underlying Joda classes would IMHO make things
more complicated than it should be. One of the drivers to move to Joda is
that in the current application we're building we have to do a lot of time
and date based calculations and Joda excels in that.

A little refactoring should not stop the improvement of the framework but
perhaps I'm missing some more relevant.

Kind Regards,

Jeroen

On Tue, Sep 18, 2012 at 7:05 PM, Kevin Meyer - KMZ <ke...@kmz.co.za> wrote:

> An immediate quick fix would be to provide a getter on the applib date
> classes that exposes the underlying Joda class... then you could get
> the full access you want, without affecting any other component (e.g.
> the Isis sql object store ;-) )
>
> Regards,
> Kevin
>
> On 18 Sep 2012 at 16:50, Jeroen van der Wal wrote:
>
> > The reason that I use Joda is because I want to access it full
> capabilities.
> >
> > +1 to mark the applib date/times as deprecated and leave it around for a
> > while. I'm volunteering to do some refactoring of Isis.
> >
> > Regards,
> >
> > Jeroen
> >
> >
> >
> >
> > On Tue, Sep 18, 2012 at 4:20 PM, Dan Haywood
> > <da...@haywood-associates.co.uk>wrote:
> >
> > > I wonder if we should just get rid of the Isis applib date/times?
>  It's not
> > > like our implementation is in any way superior to Joda (rather: it is
> > > substantially inferior).
> > >
> > >
> > >
> > > On 18 September 2012 14:54, Kevin Meyer - KMZ <ke...@kmz.co.za> wrote:
> > >
> > > > Hi all,
> > > >
> > > > This probably does not have any direct bearing on this discussion,
> but
> > > > I have converted all Isis date / time variables to (at their core)
> use
> > > > Joda time instead of Java time classes... the core Joda time property
> > > > might not be exposed, though.
> > > >
> > > > Regards,
> > > > Kevin
> > > >
> > > > On 18 Sep 2012 at 15:38, Jeroen van der Wal wrote:
> > > >
> > > > > Hi Minto,
> > > > >
> > > > > 1. UUID is not persisted by default but will be if you mark it with
> > > > > @Persistent. Don't know from the top of my head if that's also the
> case
> > > > for
> > > > > the applib.DateTime. As an alternative you can use
> > > org.joda.time.DateTime
> > > > > (which also must be annotated with @Persistent). See the
> Datanucleus
> > > > > documentation on Java types[1] for more information.
> > > > >
> > > > > 2. Collections should be marked with
> > > > > @Persistent(mappedBy="<parent class>") for a 1-N relationship. Add
> an
> > > > > additional @Join to create a separate join table. Again,
> Datanucleus
> > > > > provides loads of documentation on this topic [2].
> > > > >
> > > > > Hope this helps.
> > > > >
> > > > > Jeroen
> > > > >
> > > > > [1] http://www.datanucleus.org/products/datanucleus/jdo/types.html
> > > > > [2]
> > > > >
> > > >
> > >
> http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_many_set.html
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Jeroen van der Wal
> > > > > Stromboli b.v.
> > > > > +31 655 874050
>
>

Re: Stuck on using JDO object store.

Posted by Kevin Meyer - KMZ <ke...@kmz.co.za>.
An immediate quick fix would be to provide a getter on the applib date 
classes that exposes the underlying Joda class... then you could get 
the full access you want, without affecting any other component (e.g. 
the Isis sql object store ;-) )

Regards,
Kevin

On 18 Sep 2012 at 16:50, Jeroen van der Wal wrote:

> The reason that I use Joda is because I want to access it full capabilities.
> 
> +1 to mark the applib date/times as deprecated and leave it around for a
> while. I'm volunteering to do some refactoring of Isis.
> 
> Regards,
> 
> Jeroen
> 
> 
> 
> 
> On Tue, Sep 18, 2012 at 4:20 PM, Dan Haywood
> <da...@haywood-associates.co.uk>wrote:
> 
> > I wonder if we should just get rid of the Isis applib date/times?  It's not
> > like our implementation is in any way superior to Joda (rather: it is
> > substantially inferior).
> >
> >
> >
> > On 18 September 2012 14:54, Kevin Meyer - KMZ <ke...@kmz.co.za> wrote:
> >
> > > Hi all,
> > >
> > > This probably does not have any direct bearing on this discussion, but
> > > I have converted all Isis date / time variables to (at their core) use
> > > Joda time instead of Java time classes... the core Joda time property
> > > might not be exposed, though.
> > >
> > > Regards,
> > > Kevin
> > >
> > > On 18 Sep 2012 at 15:38, Jeroen van der Wal wrote:
> > >
> > > > Hi Minto,
> > > >
> > > > 1. UUID is not persisted by default but will be if you mark it with
> > > > @Persistent. Don't know from the top of my head if that's also the case
> > > for
> > > > the applib.DateTime. As an alternative you can use
> > org.joda.time.DateTime
> > > > (which also must be annotated with @Persistent). See the Datanucleus
> > > > documentation on Java types[1] for more information.
> > > >
> > > > 2. Collections should be marked with
> > > > @Persistent(mappedBy="<parent class>") for a 1-N relationship. Add an
> > > > additional @Join to create a separate join table. Again, Datanucleus
> > > > provides loads of documentation on this topic [2].
> > > >
> > > > Hope this helps.
> > > >
> > > > Jeroen
> > > >
> > > > [1] http://www.datanucleus.org/products/datanucleus/jdo/types.html
> > > > [2]
> > > >
> > >
> > http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_many_set.html
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Jeroen van der Wal
> > > > Stromboli b.v.
> > > > +31 655 874050


Re: Stuck on using JDO object store.

Posted by Jeroen van der Wal <je...@stromboli.it>.
The reason that I use Joda is because I want to access it full capabilities.

+1 to mark the applib date/times as deprecated and leave it around for a
while. I'm volunteering to do some refactoring of Isis.

Regards,

Jeroen




On Tue, Sep 18, 2012 at 4:20 PM, Dan Haywood
<da...@haywood-associates.co.uk>wrote:

> I wonder if we should just get rid of the Isis applib date/times?  It's not
> like our implementation is in any way superior to Joda (rather: it is
> substantially inferior).
>
>
>
> On 18 September 2012 14:54, Kevin Meyer - KMZ <ke...@kmz.co.za> wrote:
>
> > Hi all,
> >
> > This probably does not have any direct bearing on this discussion, but
> > I have converted all Isis date / time variables to (at their core) use
> > Joda time instead of Java time classes... the core Joda time property
> > might not be exposed, though.
> >
> > Regards,
> > Kevin
> >
> > On 18 Sep 2012 at 15:38, Jeroen van der Wal wrote:
> >
> > > Hi Minto,
> > >
> > > 1. UUID is not persisted by default but will be if you mark it with
> > > @Persistent. Don't know from the top of my head if that's also the case
> > for
> > > the applib.DateTime. As an alternative you can use
> org.joda.time.DateTime
> > > (which also must be annotated with @Persistent). See the Datanucleus
> > > documentation on Java types[1] for more information.
> > >
> > > 2. Collections should be marked with
> > > @Persistent(mappedBy="<parent class>") for a 1-N relationship. Add an
> > > additional @Join to create a separate join table. Again, Datanucleus
> > > provides loads of documentation on this topic [2].
> > >
> > > Hope this helps.
> > >
> > > Jeroen
> > >
> > > [1] http://www.datanucleus.org/products/datanucleus/jdo/types.html
> > > [2]
> > >
> >
> http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_many_set.html
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Jeroen van der Wal
> > > Stromboli b.v.
> > > +31 655 874050
> > >
> > >
> > > On Tue, Sep 18, 2012 at 2:35 PM, <mi...@xup.nl> wrote:
> > >
> > > > Hi folks,
> > > >
> > > > I am sort of stuck when using the JDO object store. I basically have
> 2
> > > > issues that I need to resolve.
> > > >
> > > > Issue 1: UUID and DateTime are not stored
> > > > ------------------------------**------------
> > > > When creating a new Report (without any statuses) the timestamp and
> > uuid
> > > > are automatically generated. So on initial create there are no edit
> > fields
> > > > for these 2 properties as expected. Pressing 'Ok' stores the
> > information in
> > > > the database and shows the details view where both fields are shown
> > with
> > > > proper data.
> > > > However when retrieving the same record from the database both these
> > > > fields are shown empty.
> > > >
> > > > What could have caused this behaviour (where do I have to look)?
> > > > Do I have to do something special to get these values to be stored as
> > well?
> > > >
> > > > Issue 2: Statusses are not attached to report
> > > > ------------------------------**---------------
> > > > I have troubles adding a status to the report. When looking in the
> > > > database I find tables for both Report and Status. But I can not find
> > any
> > > > relation between both tables.
> > > >
> > > > I am probably overlooking something but I can't figure out what?
> > > >
> > > > Model:
> > > > ------
> > > > class Report {
> > > >   UUID uuid;
> > > >   DateTime timestamp        // Isis DateTime
> > > >   String reporter;
> > > >   String reason;
> > > >   List<Status> statuses;
> > > > }
> > > >
> > > > class Status {
> > > >   DateTime timestamp        // Isis DateTime
> > > >   String remark;
> > > >   Integer statusValue;
> > > > }
> > > >
> > > > - For UUID I created a ValueSemanticsProvider. The value is shown
> > properly
> > > > on screen.
> > > > - The ReportRepository contains methods for creating a new Report and
> > > > searching for reports.
> > > > - Statuses are created through Report.addStatus() looking something
> > like
> > > > this:
> > > >
> > > >   public void addStatus( @Named("Partij") Integer partij,
> > > >       @Named("Duider") String duider,
> > > >       @Named("Status") Integer status,
> > > >       @Named("Toelichting") String toelichting) {
> > > >     final Status statusObject = newTransientInstance(Status.**class);
> > > >     statusObject.set...
> > > >     statuses.add(statusObject);   // Shouldn't 'this' be saved as
> well?
> > > >     persist(statusObject);
> > > >   }
> > > >
> > > >
> > > > Environment:
> > > > ------------
> > > > 0.3.1-SNAPSHOT
> > > > JDO objectstore on postgresql
> > > > Html viewer
> > > >
> > > > Any help is greatly appreciated.
> > > >
> > > > Regards,
> > > >
> > > > Minto
> >
> >
>

Re: Stuck on using JDO object store.

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
I wonder if we should just get rid of the Isis applib date/times?  It's not
like our implementation is in any way superior to Joda (rather: it is
substantially inferior).



On 18 September 2012 14:54, Kevin Meyer - KMZ <ke...@kmz.co.za> wrote:

> Hi all,
>
> This probably does not have any direct bearing on this discussion, but
> I have converted all Isis date / time variables to (at their core) use
> Joda time instead of Java time classes... the core Joda time property
> might not be exposed, though.
>
> Regards,
> Kevin
>
> On 18 Sep 2012 at 15:38, Jeroen van der Wal wrote:
>
> > Hi Minto,
> >
> > 1. UUID is not persisted by default but will be if you mark it with
> > @Persistent. Don't know from the top of my head if that's also the case
> for
> > the applib.DateTime. As an alternative you can use org.joda.time.DateTime
> > (which also must be annotated with @Persistent). See the Datanucleus
> > documentation on Java types[1] for more information.
> >
> > 2. Collections should be marked with
> > @Persistent(mappedBy="<parent class>") for a 1-N relationship. Add an
> > additional @Join to create a separate join table. Again, Datanucleus
> > provides loads of documentation on this topic [2].
> >
> > Hope this helps.
> >
> > Jeroen
> >
> > [1] http://www.datanucleus.org/products/datanucleus/jdo/types.html
> > [2]
> >
> http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_many_set.html
> >
> >
> >
> >
> >
> > --
> > Jeroen van der Wal
> > Stromboli b.v.
> > +31 655 874050
> >
> >
> > On Tue, Sep 18, 2012 at 2:35 PM, <mi...@xup.nl> wrote:
> >
> > > Hi folks,
> > >
> > > I am sort of stuck when using the JDO object store. I basically have 2
> > > issues that I need to resolve.
> > >
> > > Issue 1: UUID and DateTime are not stored
> > > ------------------------------**------------
> > > When creating a new Report (without any statuses) the timestamp and
> uuid
> > > are automatically generated. So on initial create there are no edit
> fields
> > > for these 2 properties as expected. Pressing 'Ok' stores the
> information in
> > > the database and shows the details view where both fields are shown
> with
> > > proper data.
> > > However when retrieving the same record from the database both these
> > > fields are shown empty.
> > >
> > > What could have caused this behaviour (where do I have to look)?
> > > Do I have to do something special to get these values to be stored as
> well?
> > >
> > > Issue 2: Statusses are not attached to report
> > > ------------------------------**---------------
> > > I have troubles adding a status to the report. When looking in the
> > > database I find tables for both Report and Status. But I can not find
> any
> > > relation between both tables.
> > >
> > > I am probably overlooking something but I can't figure out what?
> > >
> > > Model:
> > > ------
> > > class Report {
> > >   UUID uuid;
> > >   DateTime timestamp        // Isis DateTime
> > >   String reporter;
> > >   String reason;
> > >   List<Status> statuses;
> > > }
> > >
> > > class Status {
> > >   DateTime timestamp        // Isis DateTime
> > >   String remark;
> > >   Integer statusValue;
> > > }
> > >
> > > - For UUID I created a ValueSemanticsProvider. The value is shown
> properly
> > > on screen.
> > > - The ReportRepository contains methods for creating a new Report and
> > > searching for reports.
> > > - Statuses are created through Report.addStatus() looking something
> like
> > > this:
> > >
> > >   public void addStatus( @Named("Partij") Integer partij,
> > >       @Named("Duider") String duider,
> > >       @Named("Status") Integer status,
> > >       @Named("Toelichting") String toelichting) {
> > >     final Status statusObject = newTransientInstance(Status.**class);
> > >     statusObject.set...
> > >     statuses.add(statusObject);   // Shouldn't 'this' be saved as well?
> > >     persist(statusObject);
> > >   }
> > >
> > >
> > > Environment:
> > > ------------
> > > 0.3.1-SNAPSHOT
> > > JDO objectstore on postgresql
> > > Html viewer
> > >
> > > Any help is greatly appreciated.
> > >
> > > Regards,
> > >
> > > Minto
>
>

Re: Stuck on using JDO object store.

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
I wonder if we should just get rid of the Isis applib date/times?  It's not
like our implementation is in any way superior to Joda (rather: it is
substantially inferior).



On 18 September 2012 14:54, Kevin Meyer - KMZ <ke...@kmz.co.za> wrote:

> Hi all,
>
> This probably does not have any direct bearing on this discussion, but
> I have converted all Isis date / time variables to (at their core) use
> Joda time instead of Java time classes... the core Joda time property
> might not be exposed, though.
>
> Regards,
> Kevin
>
> On 18 Sep 2012 at 15:38, Jeroen van der Wal wrote:
>
> > Hi Minto,
> >
> > 1. UUID is not persisted by default but will be if you mark it with
> > @Persistent. Don't know from the top of my head if that's also the case
> for
> > the applib.DateTime. As an alternative you can use org.joda.time.DateTime
> > (which also must be annotated with @Persistent). See the Datanucleus
> > documentation on Java types[1] for more information.
> >
> > 2. Collections should be marked with
> > @Persistent(mappedBy="<parent class>") for a 1-N relationship. Add an
> > additional @Join to create a separate join table. Again, Datanucleus
> > provides loads of documentation on this topic [2].
> >
> > Hope this helps.
> >
> > Jeroen
> >
> > [1] http://www.datanucleus.org/products/datanucleus/jdo/types.html
> > [2]
> >
> http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_many_set.html
> >
> >
> >
> >
> >
> > --
> > Jeroen van der Wal
> > Stromboli b.v.
> > +31 655 874050
> >
> >
> > On Tue, Sep 18, 2012 at 2:35 PM, <mi...@xup.nl> wrote:
> >
> > > Hi folks,
> > >
> > > I am sort of stuck when using the JDO object store. I basically have 2
> > > issues that I need to resolve.
> > >
> > > Issue 1: UUID and DateTime are not stored
> > > ------------------------------**------------
> > > When creating a new Report (without any statuses) the timestamp and
> uuid
> > > are automatically generated. So on initial create there are no edit
> fields
> > > for these 2 properties as expected. Pressing 'Ok' stores the
> information in
> > > the database and shows the details view where both fields are shown
> with
> > > proper data.
> > > However when retrieving the same record from the database both these
> > > fields are shown empty.
> > >
> > > What could have caused this behaviour (where do I have to look)?
> > > Do I have to do something special to get these values to be stored as
> well?
> > >
> > > Issue 2: Statusses are not attached to report
> > > ------------------------------**---------------
> > > I have troubles adding a status to the report. When looking in the
> > > database I find tables for both Report and Status. But I can not find
> any
> > > relation between both tables.
> > >
> > > I am probably overlooking something but I can't figure out what?
> > >
> > > Model:
> > > ------
> > > class Report {
> > >   UUID uuid;
> > >   DateTime timestamp        // Isis DateTime
> > >   String reporter;
> > >   String reason;
> > >   List<Status> statuses;
> > > }
> > >
> > > class Status {
> > >   DateTime timestamp        // Isis DateTime
> > >   String remark;
> > >   Integer statusValue;
> > > }
> > >
> > > - For UUID I created a ValueSemanticsProvider. The value is shown
> properly
> > > on screen.
> > > - The ReportRepository contains methods for creating a new Report and
> > > searching for reports.
> > > - Statuses are created through Report.addStatus() looking something
> like
> > > this:
> > >
> > >   public void addStatus( @Named("Partij") Integer partij,
> > >       @Named("Duider") String duider,
> > >       @Named("Status") Integer status,
> > >       @Named("Toelichting") String toelichting) {
> > >     final Status statusObject = newTransientInstance(Status.**class);
> > >     statusObject.set...
> > >     statuses.add(statusObject);   // Shouldn't 'this' be saved as well?
> > >     persist(statusObject);
> > >   }
> > >
> > >
> > > Environment:
> > > ------------
> > > 0.3.1-SNAPSHOT
> > > JDO objectstore on postgresql
> > > Html viewer
> > >
> > > Any help is greatly appreciated.
> > >
> > > Regards,
> > >
> > > Minto
>
>

Re: Stuck on using JDO object store.

Posted by Kevin Meyer - KMZ <ke...@kmz.co.za>.
Hi all,

This probably does not have any direct bearing on this discussion, but 
I have converted all Isis date / time variables to (at their core) use 
Joda time instead of Java time classes... the core Joda time property 
might not be exposed, though.

Regards,
Kevin

On 18 Sep 2012 at 15:38, Jeroen van der Wal wrote:

> Hi Minto,
> 
> 1. UUID is not persisted by default but will be if you mark it with
> @Persistent. Don't know from the top of my head if that's also the case for
> the applib.DateTime. As an alternative you can use org.joda.time.DateTime
> (which also must be annotated with @Persistent). See the Datanucleus
> documentation on Java types[1] for more information.
> 
> 2. Collections should be marked with
> @Persistent(mappedBy="<parent class>") for a 1-N relationship. Add an
> additional @Join to create a separate join table. Again, Datanucleus
> provides loads of documentation on this topic [2].
> 
> Hope this helps.
> 
> Jeroen
> 
> [1] http://www.datanucleus.org/products/datanucleus/jdo/types.html
> [2]
> http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_many_set.html
> 
> 
> 
> 
> 
> -- 
> Jeroen van der Wal
> Stromboli b.v.
> +31 655 874050
> 
> 
> On Tue, Sep 18, 2012 at 2:35 PM, <mi...@xup.nl> wrote:
> 
> > Hi folks,
> >
> > I am sort of stuck when using the JDO object store. I basically have 2
> > issues that I need to resolve.
> >
> > Issue 1: UUID and DateTime are not stored
> > ------------------------------**------------
> > When creating a new Report (without any statuses) the timestamp and uuid
> > are automatically generated. So on initial create there are no edit fields
> > for these 2 properties as expected. Pressing 'Ok' stores the information in
> > the database and shows the details view where both fields are shown with
> > proper data.
> > However when retrieving the same record from the database both these
> > fields are shown empty.
> >
> > What could have caused this behaviour (where do I have to look)?
> > Do I have to do something special to get these values to be stored as well?
> >
> > Issue 2: Statusses are not attached to report
> > ------------------------------**---------------
> > I have troubles adding a status to the report. When looking in the
> > database I find tables for both Report and Status. But I can not find any
> > relation between both tables.
> >
> > I am probably overlooking something but I can't figure out what?
> >
> > Model:
> > ------
> > class Report {
> >   UUID uuid;
> >   DateTime timestamp        // Isis DateTime
> >   String reporter;
> >   String reason;
> >   List<Status> statuses;
> > }
> >
> > class Status {
> >   DateTime timestamp        // Isis DateTime
> >   String remark;
> >   Integer statusValue;
> > }
> >
> > - For UUID I created a ValueSemanticsProvider. The value is shown properly
> > on screen.
> > - The ReportRepository contains methods for creating a new Report and
> > searching for reports.
> > - Statuses are created through Report.addStatus() looking something like
> > this:
> >
> >   public void addStatus( @Named("Partij") Integer partij,
> >       @Named("Duider") String duider,
> >       @Named("Status") Integer status,
> >       @Named("Toelichting") String toelichting) {
> >     final Status statusObject = newTransientInstance(Status.**class);
> >     statusObject.set...
> >     statuses.add(statusObject);   // Shouldn't 'this' be saved as well?
> >     persist(statusObject);
> >   }
> >
> >
> > Environment:
> > ------------
> > 0.3.1-SNAPSHOT
> > JDO objectstore on postgresql
> > Html viewer
> >
> > Any help is greatly appreciated.
> >
> > Regards,
> >
> > Minto


Re: Stuck on using JDO object store.

Posted by Minto van der Sluis <mi...@xup.nl>.
Thanks Dan!

I'll give it a try when I am back at the office.

Regars,

Minto

PS. Regarding code formatting I prefer my own formatting (me being
stubborn ;-) which is consistent over my isis and not isis projects. But
thanks for the tip anyways. To reduce boilerplate (getters and setters)
I mostly use Lombok.

Op 22-9-2012 9:05, Dan Haywood schreef:
> Aha!  Have found the problem.  It's a good one.
> 
> The problem was that DataNucleus didn't seem to have replaced the Parent's
> ArrayList with its own RDBMS-aware equivalent:
> 
>   @Persistent(mappedBy="parent")
>   private final List<Child> children = new ArrayList<Child>();
> 
> And the reason for that is "final".
> 
> So, instead, this should read:
> 
>   @Persistent(mappedBy="parent")
>   private List<Child> children = new ArrayList<Child>();
> 
> 
> Fixing this then discovered a second issue.  JDO/DataNucleus gives us
> persistence-by-reachability.  In the addChild() method, you had:
> 
>   public void addChild( @Named("Name") String name ) {
>     final Child child = newTransientInstance(Child.class);
>     child.setName(name);
>     addToChildren(child);
>     persist(child);
>   }
> 
> However, attaching the child to the parent will cause it to be persisted,
> and then calling persist() once again makes Isis throw an exception.  So, I
> changed the code to:
> 
>   public void addChild( @Named("Name") String name ) {
>     final Child child = newTransientInstance(Child.class);
>     child.setName(name);
>     addToChildren(child);
>     persistIfNotAlready(child);
>   }
> 
> and it worked.
> 
> This might indicate a slight inconsistency in the OS implementations.  Not
> sure yet whether that's an issue or not.  One (simple) solution is to
> change the semantics of persist() to be persistIfNotAlready()... that
> happens to be closer to JDO's semantics, and I don't think would break any
> other design assumptions in Isis.
> 
> Anyway, you should be good to go.
> 
> Cheers
> Dan
> 
> PS: looking at your code, you might want to check out the CoffeeBytes
> plugin along with the Eclipse templates, both on the Isis website [1].
> 
> 
> [1]http://incubator.apache.org/isis/ide-support.html
> 


-- 
ir. ing. Minto van der Sluis
Software innovator / renovator
Xup BV

Mobiel: +31 (0) 626 014541

Re: Stuck on using JDO object store.

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Aha!  Have found the problem.  It's a good one.

The problem was that DataNucleus didn't seem to have replaced the Parent's
ArrayList with its own RDBMS-aware equivalent:

  @Persistent(mappedBy="parent")
  private final List<Child> children = new ArrayList<Child>();

And the reason for that is "final".

So, instead, this should read:

  @Persistent(mappedBy="parent")
  private List<Child> children = new ArrayList<Child>();


Fixing this then discovered a second issue.  JDO/DataNucleus gives us
persistence-by-reachability.  In the addChild() method, you had:

  public void addChild( @Named("Name") String name ) {
    final Child child = newTransientInstance(Child.class);
    child.setName(name);
    addToChildren(child);
    persist(child);
  }

However, attaching the child to the parent will cause it to be persisted,
and then calling persist() once again makes Isis throw an exception.  So, I
changed the code to:

  public void addChild( @Named("Name") String name ) {
    final Child child = newTransientInstance(Child.class);
    child.setName(name);
    addToChildren(child);
    persistIfNotAlready(child);
  }

and it worked.

This might indicate a slight inconsistency in the OS implementations.  Not
sure yet whether that's an issue or not.  One (simple) solution is to
change the semantics of persist() to be persistIfNotAlready()... that
happens to be closer to JDO's semantics, and I don't think would break any
other design assumptions in Isis.

Anyway, you should be good to go.

Cheers
Dan

PS: looking at your code, you might want to check out the CoffeeBytes
plugin along with the Eclipse templates, both on the Isis website [1].


[1]http://incubator.apache.org/isis/ide-support.html

Re: Stuck on using JDO object store.

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
thx.  Not gonna get a chance to look at it today, I'm afraid.  Will try to
in next couple of days, though.


On 21 September 2012 13:43, <mi...@xup.nl> wrote:

> Hi,
>
> Quoting Dan Haywood <da...@haywood-associates.co.uk>**:
>
>  On 21 September 2012 08:26, <mi...@xup.nl> wrote:
>>
>>  Hi Dan,
>>>
>>>
>>>
>>> Quoting Dan Haywood <da...@haywood-associates.co.uk>****:
>>>
>>> Unfortunately the wicket viewer has the same (incorrect) behaviour. I
>>> will
>>>
>>>> try to provide a small sample application showing this issue.
>>>>
>>>
>>>
>>>  Thanks.  Github is great for hosting such demo apps; I did one yesterday
>> for a problem I found in Wicket [1]
>>
>>
> I'v added a small project under: https://github.com/misl/**
> apache-isis-family-example<https://github.com/misl/apache-isis-family-example>
>
> To start is use the following command on either the HTML or Wicket viewer:
>
>    mvn tomcat7:run-war -P local
>
> This uses the JDO with am HSQLDB in memory database.
>
> Please note the ISIS-262 and ISIS-271 are required for this example to run.
>
> Hopefully the problem is on my side in incorrectly using the JDO
> annotations. I had another look at the JDO documentation but still came to
> the same result. Right now I use:
>
>   @Persistent(mappedBy="parent")
>   private final List<Child> children = new ArrayList<Child>();
>
> Regards,
>
> Minto
>
>

Re: Stuck on using JDO object store.

Posted by mi...@xup.nl.
Hi,

Quoting Dan Haywood <da...@haywood-associates.co.uk>:

> On 21 September 2012 08:26, <mi...@xup.nl> wrote:
>
>> Hi Dan,
>>
>>
>> Quoting Dan Haywood <da...@haywood-associates.co.uk>**:
>>
>> Unfortunately the wicket viewer has the same (incorrect) behaviour. I will
>>> try to provide a small sample application showing this issue.
>>
>>
> Thanks.  Github is great for hosting such demo apps; I did one yesterday
> for a problem I found in Wicket [1]
>

I'v added a small project under:  
https://github.com/misl/apache-isis-family-example

To start is use the following command on either the HTML or Wicket viewer:

    mvn tomcat7:run-war -P local

This uses the JDO with am HSQLDB in memory database.

Please note the ISIS-262 and ISIS-271 are required for this example to run.

Hopefully the problem is on my side in incorrectly using the JDO  
annotations. I had another look at the JDO documentation but still  
came to the same result. Right now I use:

   @Persistent(mappedBy="parent")
   private final List<Child> children = new ArrayList<Child>();

Regards,

Minto


Re: Stuck on using JDO object store.

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 21 September 2012 08:26, <mi...@xup.nl> wrote:

> Hi Dan,
>
>
> Quoting Dan Haywood <da...@haywood-associates.co.uk>**:
>
> Unfortunately the wicket viewer has the same (incorrect) behaviour. I will
>> try to provide a small sample application showing this issue.
>
>
Thanks.  Github is great for hosting such demo apps; I did one yesterday
for a problem I found in Wicket [1]



>
>> ~~~
>> Separately, picking up on an earlier part of your thread, you mentioned
>> that you'd written a ValueSemanticsProvider for UUID.  Would you mind
>> contributing this back to Isis (ie raise a ticket, attach a patch as per
>> normal)?
>>
>>
> I will. First I have to repackage it. I also have ValueSemanticProviders
> for URI  (java.net.URI)


... thanks for all this; these can go into the core applib.



> and IRI (org.apache.abdera.i18n.iri.**IRI). Mostly because of the last
> one I wondered if some sort of isis-contrib library is appropriate here.
> Otherwise too many dependencies will be added to the core progmodel.
>
>
Indeed.  There is a (currently) empty project [2] under
apache-extras.orgfor this purpose.  I've taken the liberty of adding
you as a committer.

Dan



>
> Regards,
>
> Minto
>

[1] https://github.com/danhaywood/wicket-4773
[2] http://code.google.com/a/apache-extras.org/p/isis-extras/

Re: Stuck on using JDO object store.

Posted by mi...@xup.nl.
Hi Dan,

Quoting Dan Haywood <da...@haywood-associates.co.uk>:

> The short answer, unfortunately, is no.  "Unfortunately" because it means
> I can't tell you what is wrong.
>
> So, you're saying that the data is correctly stored in the database, but is
> not being shown in the HTML viewer?  Is it there in the Wicket viewer or
> the Restful viewer?
>
Unfortunately the wicket viewer has the same (incorrect) behaviour. I  
will try to provide a small sample application showing this issue.
>
> ~~~
> Separately, picking up on an earlier part of your thread, you mentioned
> that you'd written a ValueSemanticsProvider for UUID.  Would you mind
> contributing this back to Isis (ie raise a ticket, attach a patch as per
> normal)?
>

I will. First I have to repackage it. I also have  
ValueSemanticProviders for URI  (java.net.URI) and IRI  
(org.apache.abdera.i18n.iri.IRI). Mostly because of the last one I  
wondered if some sort of isis-contrib library is appropriate here.  
Otherwise too many dependencies will be added to the core progmodel.


Regards,

Minto

Re: Stuck on using JDO object store.

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Hi Minto,
just catching up with my emails here... sorry not to come back to you on
your query here...

On 19 September 2012 13:10, <mi...@xup.nl> wrote:

>
> However there still remains 1 issue. Using the HTML viewer new data is
> stored in the database properly. Also the relation between both entities.
> However when retrieving the data from the database the collection fields
> are still empty.
>
> Is this some lazy loading that needs to be specified additionally?
>
> The short answer, unfortunately, is no.  "Unfortunately" because it means
I can't tell you what is wrong.

So, you're saying that the data is correctly stored in the database, but is
not being shown in the HTML viewer?  Is it there in the Wicket viewer or
the Restful viewer?


~~~
Separately, picking up on an earlier part of your thread, you mentioned
that you'd written a ValueSemanticsProvider for UUID.  Would you mind
contributing this back to Isis (ie raise a ticket, attach a patch as per
normal)?

Dan



> Regards,
>
> Minto
>
>

Re: Stuck on using JDO object store.

Posted by mi...@xup.nl.
Hi folks,

Thanks for all the information. I was able to solve some of the issues.

1. UUID missing in database
Since the UUID is actually just an ID I switched to the appropriate  
JDO ID generator strategy:

   @DatastoreIdentity(strategy=IdGeneratorStrategy.UUIDHEX)

2. Timestamp missing in database
All that was required to have the timestamp included in the database  
was added the persistent annotation to it.

     @Persistent

3. 1-to-many relation.
The JDO documentation was really helpfull. On the collection fields in  
my model I had to add the following line:

   @Persistent(mappedBy="<fieldname in the class>")

This results in a database with the proper relation between both tables.

However there still remains 1 issue. Using the HTML viewer new data is  
stored in the database properly. Also the relation between both  
entities. However when retrieving the data from the database the  
collection fields are still empty.

Is this some lazy loading that needs to be specified additionally?

Regards,

Minto

Quoting Jeroen van der Wal <je...@stromboli.it>:

> Hi Minto,
>
> 1. UUID is not persisted by default but will be if you mark it with
> @Persistent. Don't know from the top of my head if that's also the case for
> the applib.DateTime. As an alternative you can use org.joda.time.DateTime
> (which also must be annotated with @Persistent). See the Datanucleus
> documentation on Java types[1] for more information.
>
> 2. Collections should be marked with
> @Persistent(mappedBy="<parent class>") for a 1-N relationship. Add an
> additional @Join to create a separate join table. Again, Datanucleus
> provides loads of documentation on this topic [2].
>
> Hope this helps.
>
> Jeroen
>
> [1] http://www.datanucleus.org/products/datanucleus/jdo/types.html
> [2]
> http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_many_set.html
>
>
>
>
>
> --
> Jeroen van der Wal
> Stromboli b.v.
> +31 655 874050
>
>
> On Tue, Sep 18, 2012 at 2:35 PM, <mi...@xup.nl> wrote:
>
>> Hi folks,
>>
>> I am sort of stuck when using the JDO object store. I basically have 2
>> issues that I need to resolve.
>>
>> Issue 1: UUID and DateTime are not stored
>> ------------------------------**------------
>> When creating a new Report (without any statuses) the timestamp and uuid
>> are automatically generated. So on initial create there are no edit fields
>> for these 2 properties as expected. Pressing 'Ok' stores the information in
>> the database and shows the details view where both fields are shown with
>> proper data.
>> However when retrieving the same record from the database both these
>> fields are shown empty.
>>
>> What could have caused this behaviour (where do I have to look)?
>> Do I have to do something special to get these values to be stored as well?
>>
>> Issue 2: Statusses are not attached to report
>> ------------------------------**---------------
>> I have troubles adding a status to the report. When looking in the
>> database I find tables for both Report and Status. But I can not find any
>> relation between both tables.
>>
>> I am probably overlooking something but I can't figure out what?
>>
>> Model:
>> ------
>> class Report {
>>   UUID uuid;
>>   DateTime timestamp        // Isis DateTime
>>   String reporter;
>>   String reason;
>>   List<Status> statuses;
>> }
>>
>> class Status {
>>   DateTime timestamp        // Isis DateTime
>>   String remark;
>>   Integer statusValue;
>> }
>>
>> - For UUID I created a ValueSemanticsProvider. The value is shown properly
>> on screen.
>> - The ReportRepository contains methods for creating a new Report and
>> searching for reports.
>> - Statuses are created through Report.addStatus() looking something like
>> this:
>>
>>   public void addStatus( @Named("Partij") Integer partij,
>>       @Named("Duider") String duider,
>>       @Named("Status") Integer status,
>>       @Named("Toelichting") String toelichting) {
>>     final Status statusObject = newTransientInstance(Status.**class);
>>     statusObject.set...
>>     statuses.add(statusObject);   // Shouldn't 'this' be saved as well?
>>     persist(statusObject);
>>   }
>>
>>
>> Environment:
>> ------------
>> 0.3.1-SNAPSHOT
>> JDO objectstore on postgresql
>> Html viewer
>>
>> Any help is greatly appreciated.
>>
>> Regards,
>>
>> Minto
>>
>>
>



Re: Stuck on using JDO object store.

Posted by Jeroen van der Wal <je...@stromboli.it>.
Hi Minto,

1. UUID is not persisted by default but will be if you mark it with
@Persistent. Don't know from the top of my head if that's also the case for
the applib.DateTime. As an alternative you can use org.joda.time.DateTime
(which also must be annotated with @Persistent). See the Datanucleus
documentation on Java types[1] for more information.

2. Collections should be marked with
@Persistent(mappedBy="<parent class>") for a 1-N relationship. Add an
additional @Join to create a separate join table. Again, Datanucleus
provides loads of documentation on this topic [2].

Hope this helps.

Jeroen

[1] http://www.datanucleus.org/products/datanucleus/jdo/types.html
[2]
http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_many_set.html





-- 
Jeroen van der Wal
Stromboli b.v.
+31 655 874050


On Tue, Sep 18, 2012 at 2:35 PM, <mi...@xup.nl> wrote:

> Hi folks,
>
> I am sort of stuck when using the JDO object store. I basically have 2
> issues that I need to resolve.
>
> Issue 1: UUID and DateTime are not stored
> ------------------------------**------------
> When creating a new Report (without any statuses) the timestamp and uuid
> are automatically generated. So on initial create there are no edit fields
> for these 2 properties as expected. Pressing 'Ok' stores the information in
> the database and shows the details view where both fields are shown with
> proper data.
> However when retrieving the same record from the database both these
> fields are shown empty.
>
> What could have caused this behaviour (where do I have to look)?
> Do I have to do something special to get these values to be stored as well?
>
> Issue 2: Statusses are not attached to report
> ------------------------------**---------------
> I have troubles adding a status to the report. When looking in the
> database I find tables for both Report and Status. But I can not find any
> relation between both tables.
>
> I am probably overlooking something but I can't figure out what?
>
> Model:
> ------
> class Report {
>   UUID uuid;
>   DateTime timestamp        // Isis DateTime
>   String reporter;
>   String reason;
>   List<Status> statuses;
> }
>
> class Status {
>   DateTime timestamp        // Isis DateTime
>   String remark;
>   Integer statusValue;
> }
>
> - For UUID I created a ValueSemanticsProvider. The value is shown properly
> on screen.
> - The ReportRepository contains methods for creating a new Report and
> searching for reports.
> - Statuses are created through Report.addStatus() looking something like
> this:
>
>   public void addStatus( @Named("Partij") Integer partij,
>       @Named("Duider") String duider,
>       @Named("Status") Integer status,
>       @Named("Toelichting") String toelichting) {
>     final Status statusObject = newTransientInstance(Status.**class);
>     statusObject.set...
>     statuses.add(statusObject);   // Shouldn't 'this' be saved as well?
>     persist(statusObject);
>   }
>
>
> Environment:
> ------------
> 0.3.1-SNAPSHOT
> JDO objectstore on postgresql
> Html viewer
>
> Any help is greatly appreciated.
>
> Regards,
>
> Minto
>
>