[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2946?page=c...
]
Carl Allain commented on HHH-2946:
----------------------------------
I have the same problem. I am trying to use
@Embeddable
public class I18nDescription implements Serializable {
private String languageCode;
private String description;
public I18nDescription() {
}
public I18nDescription(String languageCode, String description) {
setLanguageCode(languageCode);
setDescription(description);
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getLanguageCode() {
return languageCode;
}
public void setLanguageCode(String languageCode) {
this.languageCode = languageCode;
}
public String toString() {
return "languageCode=" + getLanguageCode() +
";description=" + getDescription();
}
}
and this
@Entity
@Table(name="PRPT_PRTT")
public class PartyTypeImpl implements Serializable, PartyType {
private Short id;
private List<I18nDescription> descriptions;
private Map<String, I18nDescription> mapOfDescriptions;
@Id
@Column(name="PRTT_ID", nullable=false)
public Short getId() {
return this.id;
}
public void setId(Short id) {
this.id = id;
}
@Transient
public List<I18nDescription> getDescriptions() {
return this.descriptions;
}
public void setDescriptions(List<I18nDescription> descriptions) {
this.descriptions = descriptions;
}
public void addDescription(I18nDescription i18nDescription) {
if (this.descriptions == null) {
this.descriptions = new
ArrayList<com.magrit.bdom.types.multilingual.I18nDescription>();
}
this.descriptions.add(i18nDescription);
}
@CollectionOfElements
@JoinTable(
name = "PRPT_PRTT1",
joinColumns = { @JoinColumn(name = "PRTT_ID") }
)
@MapKey(columns = { @Column(name = "LNG_CD") }) // MapKey of hibernate, not
javax.persistence
@Embedded
@AttributeOverrides(
value = {
@AttributeOverride(name = "languageCode", column = @Column(name =
"LNG_CD")),
@AttributeOverride(name = "description", column = @Column(name =
"PRTT_DES"))
}
)
public Map<String, I18nDescription> getMapOfDescriptions() {
return this.mapOfDescriptions;
}
public void setMapOfDescriptions(Map<String, I18nDescription> mapOfDescriptions) {
this.mapOfDescriptions = mapOfDescriptions;
}
}
and I get this:
javax.persistence.PersistenceException: org.hibernate.PropertyNotFoundException: Could not
find a setter for property bytes in class java.lang.String
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:737)
at
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at
test.persistence.util.JpaPersistenceProvider.<clinit>(JpaPersistenceProvider.java:30)
at test.persistence.util.PersistenceUtil.<clinit>(PersistenceUtil.java:28)
at hello.TestPerson.main(TestPerson.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: org.hibernate.PropertyNotFoundException: Could not find a setter for property
bytes in class java.lang.String
at
org.hibernate.property.BasicPropertyAccessor.createSetter(BasicPropertyAccessor.java:216)
at
org.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyAccessor.java:209)
at org.hibernate.mapping.Property.getSetter(Property.java:277)
at
org.hibernate.tuple.component.PojoComponentTuplizer.buildSetter(PojoComponentTuplizer.java:137)
at
org.hibernate.tuple.component.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:44)
at
org.hibernate.tuple.component.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:38)
at
org.hibernate.tuple.component.ComponentEntityModeToTuplizerMapping.<init>(ComponentEntityModeToTuplizerMapping.java:52)
at
org.hibernate.tuple.component.ComponentMetamodel.<init>(ComponentMetamodel.java:50)
at org.hibernate.mapping.Component.buildType(Component.java:152)
at org.hibernate.mapping.Component.getType(Component.java:145)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:68)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1106)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
at
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
... 11 more
java.lang.ExceptionInInitializerError
at
test.persistence.util.JpaPersistenceProvider.<clinit>(JpaPersistenceProvider.java:33)
at test.persistence.util.PersistenceUtil.<clinit>(PersistenceUtil.java:28)
at hello.TestPerson.main(TestPerson.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: javax.persistence.PersistenceException:
org.hibernate.PropertyNotFoundException: Could not find a setter for property bytes in
class java.lang.String
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:737)
at
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at
test.persistence.util.JpaPersistenceProvider.<clinit>(JpaPersistenceProvider.java:30)
... 7 more
Caused by: org.hibernate.PropertyNotFoundException: Could not find a setter for property
bytes in class java.lang.String
at
org.hibernate.property.BasicPropertyAccessor.createSetter(BasicPropertyAccessor.java:216)
at
org.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyAccessor.java:209)
at org.hibernate.mapping.Property.getSetter(Property.java:277)
at
org.hibernate.tuple.component.PojoComponentTuplizer.buildSetter(PojoComponentTuplizer.java:137)
at
org.hibernate.tuple.component.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:44)
at
org.hibernate.tuple.component.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:38)
at
org.hibernate.tuple.component.ComponentEntityModeToTuplizerMapping.<init>(ComponentEntityModeToTuplizerMapping.java:52)
at
org.hibernate.tuple.component.ComponentMetamodel.<init>(ComponentMetamodel.java:50)
at org.hibernate.mapping.Component.buildType(Component.java:152)
at org.hibernate.mapping.Component.getType(Component.java:145)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:68)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1106)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
at
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
... 11 more
java.lang.NoClassDefFoundError
at hello.TestPerson.main(TestPerson.java:72)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Exception in thread "main" java.lang.NoClassDefFoundError
at hello.TestPerson.main(TestPerson.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
@AttributeOverride of column type or name results in
PropertyNotFoundException
------------------------------------------------------------------------------
Key: HHH-2946
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2946
Project: Hibernate3
Issue Type: Bug
Environment: Hibernate 3.2.5.ga, Annotations 3.3.0.ga, Spring 2.0.7, MySQL
5.0.41-community-nt, Windows Vista
Reporter: Juan Antonio Agudo
Attachments: hibernateErrorTest.zip
When trying to map a java.util.Map<String,String> hibernate by default creates
VARCHAR(256) fields. When an attempt to alter for e.g. the column type to "TEXT"
an Exception is thrown. For example:
@CollectionOfElements
@AttributeOverride(name="element.value",
column=@Column(columnDefinition="TEXT"))
public Map<String, String> getSettings() {
return settings;
}
results in
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'sessionFactory' defined in file
[C:\Users\tag\workspace\xyz\conf\applicationContext.xml]: Invocation of init method
failed; nested exception is org.hibernate.PropertyNotFoundException: Could not find a
setter for property bytes in class java.lang.String
Caused by: org.hibernate.PropertyNotFoundException: Could not find a setter for property
bytes in class java.lang.String
at
org.hibernate.property.BasicPropertyAccessor.createSetter(BasicPropertyAccessor.java:216)
at
org.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyAccessor.java:209)
at org.hibernate.mapping.Property.getSetter(Property.java:277)
at
org.hibernate.tuple.component.PojoComponentTuplizer.buildSetter(PojoComponentTuplizer.java:137)
at
org.hibernate.tuple.component.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:44)
at
org.hibernate.tuple.component.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:38)
at
org.hibernate.tuple.component.ComponentEntityModeToTuplizerMapping.<init>(ComponentEntityModeToTuplizerMapping.java:52)
at
org.hibernate.tuple.component.ComponentMetamodel.<init>(ComponentMetamodel.java:50)
at org.hibernate.mapping.Component.buildType(Component.java:152)
at org.hibernate.mapping.Component.getType(Component.java:145)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Collection.validate(Collection.java:278)
at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:67)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1106)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
at
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
This behaviour can be reproduced and was described fully in
http://forum.hibernate.org/viewtopic.php?p=2368889#2368889
I attached an isolated sample code for review purposes.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira