[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6347) @Formula with Enum caussing NPE

Ondrej Medek (JIRA) noreply at atlassian.com
Wed Jun 22 06:16:53 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42690#action_42690 ] 

Ondrej Medek commented on HHH-6347:
-----------------------------------

Or maybe what about to fix org.hibernate.mapping.Column.getName() to return the formula when the Column is created from Formula? I see the method Column.getName() is used at more places in the Hibernate code where is may be useful.

> @Formula with Enum caussing NPE
> -------------------------------
>
>                 Key: HHH-6347
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6347
>             Project: Hibernate Core
>          Issue Type: Bug
>    Affects Versions: 3.5.3
>            Reporter: Ondrej Medek
>
> Hi,
> see [https://forum.hibernate.org/viewtopic.php?f=1&t=1002718]:
> @Formula("(my_sql_statement)")
> @Type(type="MyEnum")
> private MyEnum myField = null;
> causes
> java.lang.NullPointerException
> 	at org.hibernate.cfg.Ejb3Column.getName(Ejb3Column.java:250)
> 	at org.hibernate.cfg.annotations.SimpleValueBinder.setType(SimpleValueBinder.java:218)
> 	at org.hibernate.cfg.annotations.PropertyBinder.makePropertyAndValue(PropertyBinder.java:185)
> ...
> I think the problem is in the SimpleValueBinder.setType and a simple change should fix this:
> - 				typeParameters.setProperty( EnumType.COLUMN, columns[0].getName() );
> + 				typeParameters.setProperty( EnumType.COLUMN, columns[0].getMappingColumn() == null ? null : columns[0].getName() );

-- 
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