You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Kevin Meyer <ke...@kmz.co.za> on 2014/10/19 17:57:04 UTC
@Value and JDO
Hi guys,
I'm trying to define a custom value type, Location, similar to the gmap
example, but working only with integer values (to specify a position on a
floor plan), but I'm having issues getting the resulting value to work
with JDO.
I have:
{code}
@Value(semanticsProviderClass = BlueprintLocationSemanticsProvider.class)
public class BlueprintLocation implements Serializable {
{code}
with just two fields: and X and a Y..
where
{code}
public class BlueprintLocationSemanticsProvider implements
ValueSemanticsProvider<BlueprintLocation> {
{code}
But the JDO introspection does not pick up the property:
On my SimpleObject:
{code}
private BlueprintLocation blueprintLocation;
@javax.jdo.annotations.Column(allowsNull="true")
public BlueprintLocation getLocation() {
return blueprintLocation;
}
public void setLocation(BlueprintLocation location) {
this.blueprintLocation = location;
}
{code}
In the log:
17:52:38,921 [Schema main DEBUG] CREATE TABLE
"SimpleObject"
(
"id" BIGINT GENERATED BY DEFAULT AS IDENTITY,
"blueprint_id_OID" BIGINT NULL,
"name" NVARCHAR(255) NOT NULL,
"plan_id_OID" BIGINT NULL,
"attachment_name" NVARCHAR(255) NULL,
"attachment_mimetype" NVARCHAR(255) NULL,
"attachment_chars" CLOB NULL,
"version" BIGINT NOT NULL,
"friends_id_OID" BIGINT NULL,
"friends_INTEGER_IDX" INTEGER NULL,
CONSTRAINT "SimpleObject_PK" PRIMARY KEY ("id")
)
If I annotate BlueprintLocation with @PersistenceCapable, JDO treats it as
an entity. Using @PersistenceAware has no effect.
What am I missing?
(Does the ToDo app show an example ValueType? I have not checked...)
Thanks,
Kevin
Re: @Value and JDO
Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Yeah, that's the one.
It's also necessary to add a few more JDO annotations in the dom... the
todoapp example shows how.
Cheers
Dan
On 19 October 2014 17:41, Kevin Meyer <ke...@kmz.co.za> wrote:
> >
> >> - (optionally, but recommended), you need to implement the appropriate
> >> JDO
> >> API so that the value type is persisted in some meaningful fashion,
> >> rather than just a byte[] or blob.
> >
> > Right, so if I want to encode it as 2 fields in the underlying table, to
> > aid queries, for example.
> >
> >> The latter involves implementing an SPI and registering in
> >> META-INF/MANIFEST; have a look at how this is done for
> >> org.apache.isis.applib.annotations.Clob, for example.
> >
> > Umm... I can't find such a class definition in Eclipse.
>
> I did find:
> org.apache.isis.objectstore.jdo.datanucleus.valuetypes.IsisClobMapping
> with nearby plugin.xml
>
> Anyway, I can put that off for the moment.
>
> Thanks,
> Kevin
>
>
Re: @Value and JDO
Posted by Kevin Meyer <ke...@kmz.co.za>.
>
>> - (optionally, but recommended), you need to implement the appropriate
>> JDO
>> API so that the value type is persisted in some meaningful fashion,
>> rather than just a byte[] or blob.
>
> Right, so if I want to encode it as 2 fields in the underlying table, to
> aid queries, for example.
>
>> The latter involves implementing an SPI and registering in
>> META-INF/MANIFEST; have a look at how this is done for
>> org.apache.isis.applib.annotations.Clob, for example.
>
> Umm... I can't find such a class definition in Eclipse.
I did find:
org.apache.isis.objectstore.jdo.datanucleus.valuetypes.IsisClobMapping
with nearby plugin.xml
Anyway, I can put that off for the moment.
Thanks,
Kevin
Re: @Value and JDO
Posted by Kevin Meyer <ke...@kmz.co.za>.
On Sun, October 19, 2014 18:00, Dan Haywood wrote:
> Hi Kevin,
>
>
> Two things:
> - you need to annotate the field as @javax.jdo.annotations.Persistent
Great! Thanks, that get's it loaded as a BLOB. Good start..
> - (optionally, but recommended), you need to implement the appropriate JDO
> API so that the value type is persisted in some meaningful fashion,
> rather than just a byte[] or blob.
Right, so if I want to encode it as 2 fields in the underlying table, to
aid queries, for example.
> The latter involves implementing an SPI and registering in
> META-INF/MANIFEST; have a look at how this is done for
> org.apache.isis.applib.annotations.Clob, for example.
Umm... I can't find such a class definition in Eclipse.
Thanks for the quick help!
Regards,
Kevin
Re: @Value and JDO
Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Hi Kevin,
Two things:
- you need to annotate the field as @javax.jdo.annotations.Persistent
- (optionally, but recommended), you need to implement the appropriate JDO
API so that the value type is persisted in some meaningful fashion, rather
than just a byte[] or blob.
The latter involves implementing an SPI and registering in
META-INF/MANIFEST; have a look at how this is done for
org.apache.isis.applib.annotations.Clob, for example.
I can dig out some further references if the above is too vague.
Cheers
Dan
On 19 October 2014 16:57, Kevin Meyer <ke...@kmz.co.za> wrote:
> Hi guys,
>
> I'm trying to define a custom value type, Location, similar to the gmap
> example, but working only with integer values (to specify a position on a
> floor plan), but I'm having issues getting the resulting value to work
> with JDO.
>
> I have:
> {code}
> @Value(semanticsProviderClass = BlueprintLocationSemanticsProvider.class)
> public class BlueprintLocation implements Serializable {
> {code}
> with just two fields: and X and a Y..
>
> where
> {code}
> public class BlueprintLocationSemanticsProvider implements
> ValueSemanticsProvider<BlueprintLocation> {
> {code}
>
> But the JDO introspection does not pick up the property:
> On my SimpleObject:
>
> {code}
> private BlueprintLocation blueprintLocation;
> @javax.jdo.annotations.Column(allowsNull="true")
> public BlueprintLocation getLocation() {
> return blueprintLocation;
> }
> public void setLocation(BlueprintLocation location) {
> this.blueprintLocation = location;
> }
>
> {code}
>
> In the log:
>
> 17:52:38,921 [Schema main DEBUG] CREATE TABLE
> "SimpleObject"
> (
> "id" BIGINT GENERATED BY DEFAULT AS IDENTITY,
> "blueprint_id_OID" BIGINT NULL,
> "name" NVARCHAR(255) NOT NULL,
> "plan_id_OID" BIGINT NULL,
> "attachment_name" NVARCHAR(255) NULL,
> "attachment_mimetype" NVARCHAR(255) NULL,
> "attachment_chars" CLOB NULL,
> "version" BIGINT NOT NULL,
> "friends_id_OID" BIGINT NULL,
> "friends_INTEGER_IDX" INTEGER NULL,
> CONSTRAINT "SimpleObject_PK" PRIMARY KEY ("id")
> )
>
> If I annotate BlueprintLocation with @PersistenceCapable, JDO treats it as
> an entity. Using @PersistenceAware has no effect.
>
> What am I missing?
>
> (Does the ToDo app show an example ValueType? I have not checked...)
>
> Thanks,
> Kevin
>
>