[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2946) @AttributeOverride of column type or name results in PropertyNotFoundException

Juan Antonio Agudo (JIRA) noreply at atlassian.com
Tue Nov 13 15:49:29 EST 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28820 ] 

Juan Antonio Agudo commented on HHH-2946:
-----------------------------------------

There seems to be some kind of limitation to what you can do with yout index column. 
Turns out this problem is not restricted to Annotation behaviour.

If you do:

      <map name="settings" >
         <key column="id" />
         <index column="keyValue" type="string" length="255"/>
         <element column="value" type="string" length="1024" />
      </map>


you get a Table that looks perfectly okay:

mysql> desc  testentity_settings;
+----------+--------------+------+-----+---------+-------+
| Field    | Type         | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| id       | bigint(20)   | NO   | PRI |         |       |
| value    | text         | YES  |     | NULL    |       |
| keyValue | varchar(255) | NO   | PRI |         |       |
+----------+--------------+------+-----+---------+-------+


However if you decide you want a text field as your index column:

      <map name="settings" >
         <key column="id" />
         <index column="keyValue" type="string" length="1024"/>
         <element column="value" type="string" length="1024" />
      </map>


The DDL Creation fails and everything just dies. This is not doumented behaviour as far as I know.

> @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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list