Well. same problems with the new version :-(
Clean project, Grails 1.0.1
Two domain objects in a bi-directional one-to-many, very simple and
classic example.
class User {
static searchable = true
String name
static hasMany = [albums:Album]
}
class Album {
static searchable = true
String title
User owner
static belongsTo= User
}
------
The following code fails when saving the user:
def u1= new User(name:'barcho king')
def a1= new Album(title:'el album del pasto en el universo')
def a2= new Album(title:'bart the king nenene')
u1.addToAlbums(a1).addToAlbums(a2)
u1.save() // FAILS HERE!
The User is actually inserted into the database:
--> insert into user (version, name) values (0, 'barcho king')
But I think the error happens when cascading down to the albums:
(example trace from within a grails controller/action, but the same
problem happens from the grails console and the BootStrap)
[102688] errors.GrailsExceptionResolver
org.compass.gps.device.hibernate.HibernateGpsDeviceException:
{hibernate}: Failed while creating [User : 1]; nested exception is
org.compass.core.converter.ConversionException: Trying to marshall a
null id [id]
org.codehaus.groovy.runtime.InvokerInvocationException:
org.compass.gps.device.hibernate.HibernateGpsDeviceException:
{hibernate}: Failed while creating [User : 1]; nested exception is
org.compass.core.converter.ConversionException: Trying to marshall a
null id [id]
[...]
at
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
[...]
Caused by: org.compass.gps.device.hibernate.HibernateGpsDeviceException:
{hibernate}: Failed while creating [User : 1]; nested exception is
org.compass.core.converter.ConversionException: Trying to marshall a
null id [id]
at
org.compass.gps.device.hibernate.dep.Hibernate3GpsDevice$Hibernate3GpsDevicePostInsert.onPostInsert(Hibernate3GpsDevice.java:186)
at $Proxy6.saveOrUpdate(Unknown Source)
[...]
at UserController$_closure2.doCall(UserController.groovy:28)
at UserController$_closure2.doCall(UserController.groovy)
Caused by: org.compass.core.converter.ConversionException: Trying to
marshall a null id [id]
at
org.compass.core.converter.mapping.osem.ClassMappingConverter.convertId(ClassMappingConverter.java:334)
at
org.compass.core.converter.mapping.osem.ClassMappingConverter.marshallIds(ClassMappingConverter.java:312)
at
org.compass.core.marshall.DefaultMarshallingStrategy.marshallIds(DefaultMarshallingStrategy.java:83)
at
org.compass.core.converter.mapping.osem.ReferenceMappingConverter.doMarshall(ReferenceMappingConverter.java:71)
at
org.compass.core.converter.mapping.osem.AbstractRefAliasMappingConverter.marshall(AbstractRefAliasMappingConverter.java:48)
at
org.compass.core.converter.mapping.osem.CollectionMappingConverter.marshallIterateData(CollectionMappingConverter.java:52)
at
org.compass.core.converter.mapping.osem.AbstractCollectionMappingConverter.marshall(AbstractCollectionMappingConverter.java:73)
at
org.compass.core.converter.mapping.osem.ClassMappingConverter.doMarshall(ClassMappingConverter.java:155)
at
org.compass.core.converter.mapping.osem.ClassMappingConverter.marshall(ClassMappingConverter.java:63)
at
org.compass.core.marshall.DefaultMarshallingStrategy.marshall(DefaultMarshallingStrategy.java:150)
at
org.compass.core.impl.DefaultCompassSession.create(DefaultCompassSession.java:276)
at
org.compass.gps.device.hibernate.dep.Hibernate3GpsDevice$Hibernate3GpsDevicePostInsert$1.doInCompassWithoutResult(Hibernate3GpsDevice.java:179)
at
org.compass.core.CompassCallbackWithoutResult.doInCompass(CompassCallbackWithoutResult.java:29)
at
org.compass.core.CompassTemplate.execute(CompassTemplate.java:137)
at
org.compass.core.CompassTemplate.execute(CompassTemplate.java:119)
at
org.compass.gps.impl.SingleCompassGps.executeForMirror(SingleCompassGps.java:164)
at
org.compass.gps.device.hibernate.dep.Hibernate3GpsDevice$Hibernate3GpsDevicePostInsert.onPostInsert(Hibernate3GpsDevice.java:175)
... 3 more
I've tried to change the User's mapping to:
static searchable = {
albums(component: true)
}
But then it gives lots of errors when grails starts:
[10266] context.ContextLoader Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'compassGps': Cannot resolve reference to bean 'compass'
while setting bean property 'compass'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'compass': FactoryBean threw exception on
object creation; nested exception is java.lang.NullPointerException
and lots similar to the above. This *used* to work in the old
(mid-2007) 0.4 snapshot, althouth there was some weird stuff with the
termFreqs, giving higher results than it should. Probably some
double-counting due to the component option.
I've also tried several other options for mappings, with no luck. I even
started to try annotation mapping but it gets too involved and complicated.
Now, I really do wonder how are other people using this plugin if I
can't make it work even for the simplest of examples (taken from the web
page).
I'd really like to use this plugin :-)
BarZ
Maurice Nicholson wrote:
> if you do get errors with the latest version please shout :-)
>
> yeah this is on the roadmap (in my head); the closure would be given
> an instance of the domain class so you could refer to the instance
> with it, eg,
>
> name: "bugId", value: { -> "${it.project.shortName}-${it.number}" }
>
> Compass has the concept of "dynamic-meta-data" for this but with that
> you basically define the expression as a string, which can get
> cumbersome for large expressions, because when configuring the mapping
> with native compass you're either in XML-land or annotation -land,
> neither of which are actually code :-)
>
> Regarding that trying to marshall null id bug you found, I could
> reproduce it easily with a Grails app, but then when I tried
> reproducing it in a paired down Java+Hibernate+Compass Test case, well
> of course I got a different problem! I think there are many more
> moving parts in the Grails app that I'm not yet aware of, so I need to
> do more investigation, but it's now the top priority for me.
>
>
> On 17/03/2008, *Barzilai Spinak* <
barcho@...
> <mailto:
barcho@...>> wrote:
>
> Computed constants.
> Hi Maurice, congratulations for the final release!
> I still had lots of errors from the SVN version of a couple of
> days ago,
> but I'm gonna try this one.
> I was reading the updated documentation and I found the section about
> constants.
> I understand that you can index "custom" mappings to a domain
> instance,
> that's very useful.
> What I was wondering is whether those constant mappings could be
> computed. That is, computed out of other properties (for example a
> concatenation of two properties, or maybe a substring of one of them
> plus the temperature in Madagascar at that time... some crazy
> example :-))
> Maybe it could accept a clousre, like:
> constant name: "myComputed" , value: {
> "bla"+tempMadagascar+(someProp*3) }
>
> I guess those constants are indexed when the object is
> saved/updated, so
> all the values are already there.
>
> BarZ
>
>
>
> Maurice Nicholson wrote:
> > Searchable Plugin 0.4 is finally here!
> >
> > I guess most of you have been using the 0.4-SNAPSHOT for a while, so
> > here's what's happened recently:
> >
> > * Upgraded to Compass 1.2.1 which includes Lucene 2.2
> > * Highlighting:
> >
>
http://grails.org/Searchable+Plugin+-+Searching#SearchablePlugin-Searching-Highlighting> > * Term Frequencies:
> >
>
http://grails.org/Searchable+Plugin+-+Searching#SearchablePlugin-Searching-termFreqs> > * The start of a mapping DSL:
> >
>
http://grails.org/Searchable+Plugin+-+Mapping#SearchablePlugin-Mapping-MappingDSL> > * Better default mapping of embedded domain classes:
> >
>
http://grails.org/Searchable+Plugin+-+Mapping#SearchablePlugin-Mapping-Defaultmappingrules> >
> > Cheers,
> > Maurice
> >
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email