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
>
>

Reply via email to