Although I've not tried it, you *should* be able to persist anything that
JDO supports, and that includes Maps.  [1]

However, the Isis metamodel does not recognize Maps, so you will need to
annotate its getter and setter as @Programmatic else bad things will happen
(Isis almost certainly won't boot, and will throw a meta-model violation
error)..

If you stick to using Collections rather than Maps (SortedSets are what we
recommend) then Isis will be able to render the collection.

Also, you'll find that JDO will replace the HashSet (or HashMap, or
whatever) with its own Set implementation.    There's shouldn't be any need
to use a ConcurrentHashMap, each JDO-managed entity is "owned" by a single
request/thread.

One other point: an alternative option is to serialize these data
structures to strings or similar and store in a blob.

HTH
Dan


[1]
http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_many_map.html



On 25 July 2014 14:14, Dileepa Jayakody <[email protected]> wrote:

> Hi All,
>
> Can I persist implementations of Map interface (HashMap, ConcurrentHashMap)
> and Set interface (HashSet) in Isis?
>
> In one of my entity classes I had to include these data types for data
> anlysis purposes.
> When I go through the persistence debug logs when the database is created
> at server startup, I notice that above properties in my entity class are
> not mapped to any db_schema by jdo.
>
> Thanks,
> Dileepa
>
>
> On Wed, Jul 23, 2014 at 4:44 PM, Dileepa Jayakody <
> [email protected]
> > wrote:
>
> > Thanks Oscar and Dan.
> >
> > I tried using @Column(length=1000), the max.length error is gone, but now
> > I'm getting an aborted Isis transaction [1] for some reason. Maybe it's
> due
> > to some other reason, I will check that.
> >
> > Thanks for the pointers.
> >
> > Regards,
> > Dileepa
> >
> > [1]
> > [exec] 16:39:01,440  [IsisTransaction      qtp1065406375-36 INFO ]  abort
> > transaction IsisTransaction@31117256[state=MUST_ABORT,commands=0]
> >
> >
> >
> >
> > On Wed, Jul 23, 2014 at 4:34 PM, Dan Haywood <
> [email protected]
> > > wrote:
> >
> >> On 23 July 2014 11:58, Dileepa Jayakody <[email protected]>
> >> wrote:
> >>
> >> > Hi All,
> >> >
> >> > In my project developed using Isis, I'm persisting an email entity in
> >> which
> >> > emailHeader is stored as a String.
> >> > When trying to persist the entities I get following error indicating
> the
> >> > value of emailHeaders exceed the default max.length of
> JDO/datanucleus.
> >> Can
> >> > I increase this max.length? Do I need to use another type to store the
> >> > emailHeaders?
> >> >
> >> >
> >> Or, you could use CLOB, I think, see [1]
> >>
> >> But SQL Server supports lengths up to 8000 (or is it 4000), so you might
> >> want to explore just specifying a longer length as well; it might work
> >> depending on the RDBMS you are using (as per Oscar's suggestion)
> >>
> >> Downside of using CLOB... the data is stored off-record, so is more
> >> expensive to read (for the DBMS).
> >>
> >> HTH
> >> Dan
> >>
> >> [1]
> >>
> >>
> https://github.com/apache/isis/blob/master/core/module-command-jdo/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandJdo.java#L434
> >>
> >>
> >>
> >>
> >> > Thanks,
> >> > Dileepa
> >> >
> >> >  " in column ""emailHeaders"" that has maximum length of 255. Please
> >> > correct
> >> > your data!
> >> >      [exec]     at
> >> >
> >> >
> >>
> org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:498)
> >> >      [exec]     at
> >> >
> >> >
> >>
> org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:736)
> >> >      [exec]     at
> >> >
> >> >
> >>
> org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:756)
> >> >
> >>
> >
> >
>

Reply via email to