| Summary: | Take into account optional attribute from @Basic or relationship tags for DDL generation | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Daniel Le Berre <leberre> |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | NEW --- | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | fyrewyld |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Daniel Le Berre
Just a reminder. The issue still exists in EclipseLink 2.4.1. Here is what can be read on JPA Wikibook about the optional attribute: http://en.wikibooks.org/wiki/Java_Persistence/Basic_Attributes#Optional It is really an issue IMHO that the JPA 2.0 RI does not take into account that information during DDL generation. For @Basic, the 2.1 spec describes optional with the following: "(Optional) Whether the value of the field or property may be null. This is a hint* and is disregarded for primitive types; it may be used in schema generation." So for primitive types (such as int), Eclipselink is not acting contrary to the specification. Considering that the @Column annotation also defines a "nullable" attribute, which at face value seems to do the same thing (for schema generation), it seems like there are two properties that accomplish the very same thing. Which begs the question as to the intent of the optional element, whether it should be a schema generation hint (and who wins, if it's not an error, when @Basic and @Column specify contrary values) or a runtime validation capability (which could conceivably be accomplished with Bean Validation, too.) The optional value with @ManyToOne**, as you pointed out, is pretty clear about the contract: "(Optional) Whether the association is optional. If set to false then a non-null relationship must always exist." -- the language there says nothing about it being a hint or a schema generation config element. * - The fact that it's also a hint also allows for it to be ignored, too. ** - And also @OneToOne. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |