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 <[email protected]>:
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, <[email protected]> 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