@Entity
public Tag extends Model {
...
@ElementCollection
public Map<Lang, Tag> translations;
...
}
The Lang class has just a "name" field. In the YML file for initial
data I try to load the following tag:
Tag(test):
lang: en
name: Test
translations: {en: mvc, it: play}
(other tags are one from the YABE example). When I run the application
I got the attached error. Is there a particular syntax for the YML
file ? I also tried the following annotation with same effect.
Thank you
Alternativa annotation;
@ElementCollection(targetClass = Tag.class)
@MapKeyClass(Lang.class)
public Map translations;
The error I get:
Caused by: java.lang.RuntimeException: Cannot load fixture
initial-data.yml: org.hibernate.PropertyAccessException: could not get
a field value by reflection getter of models.Lang.id
at play.test.Fixtures.loadModels(Fixtures.java:221)
at play.test.Fixtures.load(Fixtures.java:149)
at Bootstrap.doJob(Bootstrap.java:14)
at play.jobs.Job.doJobWithResult(Job.java:55)
at play.jobs.Job.call(Job.java:157)
... 1 more
Caused by: javax.persistence.PersistenceException:
org.hibernate.PropertyAccessException: could not get a field value by
reflection getter of models.Lang.id
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1147)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1153)
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:798)
at play.db.jpa.JPABase._save(JPABase.java:47)
at play.test.Fixtures.loadModels(Fixtures.java:205)
... 5 more
Caused by: org.hibernate.PropertyAccessException: could not get a
field value by reflection getter of models.Lang.id
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:62)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:227)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3875)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3583)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:203)
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:242)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:456)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:121)
at org.hibernate.persister.collection.AbstractCollectionPersister.writeIndex(AbstractCollectionPersister.java:825)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1201)
at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:58)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:188)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:345)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:795)
... 7 more
Caused by: java.lang.IllegalArgumentException: Can not set
java.lang.Long field play.db.jpa.Model.id to java.lang.String
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:59)
... 24 more
--
skype: effe.to
Lang(en):
lang: en
Lang(it):
lang: it
--
skype: effe.to
No one has never used a Map with YML ?
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
some.Graph(identifier):
parameters:
? entity
: Defect
? graphType
: temporal
? graphLabel
: Defects over time
? temporalField
: created
? xAxis
: DATE
? yAxis
: COUNT
the mapping is:
@ElementCollection(targetClass = String.class)
@MapKeyClass(String.class)
public Map<String, Object> parameters;
Something like this:
@ElementCollection(targetClass = Tag.class)
@MapKeyClass(Lang.class)
public Map translations;
The error I posted in first message rise again.
--
skype: effe.to
Yes, I did but still no luck. I get the same error.
Lang(en): &lang_en
lang: en
Lang(it): &lang_it
lang: it
Tag(test): &tag_test
lang: en
name: Test
Tag(play): &tag_play
lang: en
name: Play
Tag(mvc):
lang: en
name: MVC
translations:
? *lang_en
: *tag_test
? *lang_it
: *tag_play
--
skype: effe.to
--
skype: effe.to