On Fri, Apr 17, 2009 at 1:11 PM, Pelle Poluha <[email protected]> wrote:

> java.lang.ClassCastException: java.lang.String cannot be cast to
> groovy.lang.MetaClass
>     at $Proxy19.getMetaClass(Unknown Source)
>     ...
>     at model.message.MessageSideEffect.giveMeContent(MessageConcern.groovy:13)

> abstract class MessageSideEffect extends ConcernOf<MessageBehaviour>
> implements MessageBehaviour {
>  String giveMeContent() {
>     String s = next.giveMeContent()
>     println "sideeffect for " + s
>  }
> }
>
> Line 13 is "String s = next.giveMeContent()".

> The same code works when done in Java (ie after adding a few semi
> colons and such). Any ideas?

Try to remove the "abstract" and provide dummy methods for what you
are not interested in. The abstract class will be subclassed with
CGLib and I suspect that it could be related.


> I should also say that I've got strange
> NPE:s when initializing the composite. Like here:
>
>     SingletonAssembler assembler = new MySingletonAssembler()
>     CompositeBuilder<MessageEntity> builder =
> assembler.compositeBuilderFactory().newCompositeBuilder(MessageEntity.class)
> -->  builder.stateFor(MessageState.class).subject().set "shout"
>     builder.stateFor(MessageState.class).content().set "speak"

Can you break that down and point to exactly what is Null? And doesn
it work in Java?

> I'm planning to use the JDBM entity store (as I already planned to use
> JDBM for persistence). But I worry about how to migrate data between
> releases. The classes will change and I guess the data then will be
> inaccessible. I read a post from Aug 2007 where Rickard talked about
> migrating data using xml and xslt. Have you developed this idea
> further since then?

We have not yet designed the mechanism, and the latest break-through
in persistence (seen in recent 6 part post) will touch on this again.
It is one of the cornerstones we want to have in place prior to 1.0
release. Please note that 0.8 will contain massive changes in the
EntityStore area, and somewhat smaller ones in the UnitOfWork API
(maybe a merge() facility).

> After getting the basic things to work (like creating composites,
> calling methods without getting exceptions) the next step is to add
> associations to the classes. I guess I'll be able to figure most
> things out by looking at the existing demo apps but I wonder what will
> happen when an entity with associations gets persisted. Will all
> associated composites be persisted as well? Or only their id:s? And
> will I need an entity store for each entity or will they be able to
> share the same ES?

At persistence level, only Property, Association and ManyAssociation
are persisted. And for Property, the generic type must either be
serializable (we might even reconsider this), discrete or a
ValueComposite. For Associations, only the reference to the other
Entity is saved. And yes, you can have any number of Entity types in
the same store. In fact, you will be able to have more than one Entity
Type per Entity instance!!! Huh?? An Entity instance may be "Person"
and "TrustedEntity" although not all Persons are TrustedEntity and
vice versa. At the EntityStore level, the type is not associated
directly with the state saved.

> And one more thing. I've been searching the code base for an example
> on how to set up the JDBM entity store. But I can't find one. Not even
> the test case shows me how (as far as I can see). Could anyone provide
> me with details here?


The easiest;

in your bootstrap code;

 module.addAssembler( new JdbmEntityStoreAssembler( "jdbm-config" ) );

you will also need a 'resource' named
   org.qi4j.entitystore.jdbm.JdbmEntityStoreService.properties
containing;

###########
# The file that will contain the JDBM data.
file=qi4j.data

# If no Serializable classes uses the readObject()/writeObject() override for
# serialization, it is possible to enable the turboMode.
turboMode=false
###########

I suspect that you will want to have indexing and query capability
too, so you will also need to set up the indexing-rdf extension;

module.addAssembler( new RdfNativeSesameStoreAssembler() );



HTH


Cheers
-- 
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java

I  live here; http://tinyurl.com/2qq9er
I  work here; http://tinyurl.com/2ymelc
I relax here; http://tinyurl.com/2cgsug

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to