[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-1208) setVersion(String) accessor breaks <version type="integer"> property access at runtime
Steve Ebersole (JIRA)
noreply at atlassian.com
Mon Mar 21 13:00:24 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steve Ebersole closed HHH-1208.
-------------------------------
Closing stale resolved issues
> setVersion(String) accessor breaks <version type="integer"> property access at runtime
> --------------------------------------------------------------------------------------
>
> Key: HHH-1208
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1208
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5
> Environment: Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
> Windows 2000 SP4
> Reporter: Adam Shackleford
> Priority: Minor
>
> I'm doing absolutely vanilla versioning, using an int version, and setVersion(int)/getVersion():int accessors.
> *But* one of my persistent classes had a setVersion(String) accessor (a NOP) that I left in for backwards compatibility with objects stored by XMLEncoder that I import with XMLDecoder.
> Having setVersion(String) stops XMLDecoder from complaining that it can't find the method. The method itself does nothing.
> THE PROBLEM: The presence of setVersion(String) confuses Hibernate when I save the persistent object. It ignores the setVersion(int) and tries to call setVersion(String), which yields a "BasicPropertyAccessor ERROR - IllegalArgumentException".
> Here are the essentials:
> ----------------------------------------
> public abstract class Entity {
> private Long id;
> private int version;
> public Long getId() {
> return id;
> }
> public void setId(Long anId) {
> id = anId;
> }
> public int getVersion() {
> return version;
> }
> public void setVersion(int aVersion) {
> version = aVersion;
> }
> }
> public class Template extends Entity {
> public void setVersion(String aVersion) {
> // NOP
> }
> ...
> }
> <class name="Template" table="`TMPL`">
> <id name="id" column="`TMPL_ID`">
> <generator class="native"/>
> </id>
> <version name="version" column="`VER`"/>
> ...
> </class>
> BasicPropertyAccessor ERROR - IllegalArgumentException in class: mypackage.Template, setter method of property: version
> BasicPropertyAccessor ERROR - expected type: java.lang.String, actual value: java.lang.Integer
> AbstractFlushingEventListener ERROR - Could not synchronize database state with session
> org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of mypackage.Template.version
> ----------------------------------------
--
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