[hibernate-issues] [Hibernate-JIRA] Updated: (BVAL-234) Ignore @NotNull on JPA's @GeneratedValue properties for pre-persist operations

Hardy Ferentschik (JIRA) noreply at atlassian.com
Tue May 15 04:58:12 EDT 2012


     [ https://hibernate.onjira.com/browse/BVAL-234?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hardy Ferentschik updated BVAL-234:
-----------------------------------

    Description: 
When using NetBeans 7 to generate entity classes from a database table, the entity classes are generated with the following annotations...

{code}
public class Orders implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "orderid")
    private Integer orderid;
    // ...
}
{code}


When persisting, bean validation fails because the autogenerated primary key is null at the time the object is persisted.

Netbeans have stated that they wont fix this as they see it as bean validation issue rather than their generated classes. 

See here: http://netbeans.org/bugzilla/show_bug.cgi?id=197845

Related Forum posting is here...

https://forum.hibernate.org/viewtopic.php?f=9&t=1011908

Suggest modifying Bean Validation Pre-Persist to ignore @NotNull if @GeneratedValue exists. 

Thanks
Rich

  was:
When using NetBeans 7 to generate entity classes from a database table, the entity classes are generated with the following annotations...

{code}
public class Orders implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "orderid")
    private Integer orderid;
.....
}
{code}


When persisting, bean validation fails because the autogenerated primary key is null at the time the object is persisted.

Netbeans have stated that they wont fix this as they see it as bean validation issue rather than their generated classes. 

See here: http://netbeans.org/bugzilla/show_bug.cgi?id=197845

Related Forum posting is here...

https://forum.hibernate.org/viewtopic.php?f=9&t=1011908

Suggest modifying Bean Validation Pre-Persist to ignore @NotNull if @GeneratedValue exists. 

Thanks
Rich


> Ignore @NotNull on JPA's @GeneratedValue properties for pre-persist operations
> ------------------------------------------------------------------------------
>
>                 Key: BVAL-234
>                 URL: https://hibernate.onjira.com/browse/BVAL-234
>             Project: Bean Validation
>          Issue Type: Improvement
>          Components: spec-general
>    Affects Versions: 1.1
>         Environment: Netbeans 7, Seam 3 under JBOSS AS 7
>            Reporter: Richard Clarke
>            Priority: Minor
>              Labels: bean, validation
>   Original Estimate: 8h
>  Remaining Estimate: 8h
>
> When using NetBeans 7 to generate entity classes from a database table, the entity classes are generated with the following annotations...
> {code}
> public class Orders implements Serializable {
>     private static final long serialVersionUID = 1L;
>     @Id
>     @GeneratedValue(strategy = GenerationType.IDENTITY)
>     @Basic(optional = false)
>     @NotNull
>     @Column(name = "orderid")
>     private Integer orderid;
>     // ...
> }
> {code}
> When persisting, bean validation fails because the autogenerated primary key is null at the time the object is persisted.
> Netbeans have stated that they wont fix this as they see it as bean validation issue rather than their generated classes. 
> See here: http://netbeans.org/bugzilla/show_bug.cgi?id=197845
> Related Forum posting is here...
> https://forum.hibernate.org/viewtopic.php?f=9&t=1011908
> Suggest modifying Bean Validation Pre-Persist to ignore @NotNull if @GeneratedValue exists. 
> Thanks
> Rich

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list