| Summary: | Incorrect validation for ID classes mapped as @EmbeddedId | ||
|---|---|---|---|
| Product: | [WebTools] Dali JPA Tools | Reporter: | Karsten Wutzke <kwutzke> |
| Component: | General | Assignee: | dali.general-inbox <dali.general-inbox> |
| Status: | RESOLVED INVALID | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | neil.hauge, paul.fullbright |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| URL: | http://www.eclipse.org/forums/index.php/t/209556/ | ||
| Whiteboard: | |||
The error you are seeing is because you are requiring that all mapped classes be listed in the persistence.xml (Persistent class management in project properties) yet GroupId is not listed. You can either list GroupId in the persistence.xml or set persistent class management to "Discover annotated classes automatically" and this error should go away. The reason this error does not apply for IdClass is because an ID class is not generally annotated, but instead is interpreted in the context of the entity that uses it. If this does not match your situation, please feel free to reopen with more details. I didn't know THAT. So, when using @IdClass mappings the ID class doesn't have to be listed and when using @EmbeddedId the ID class must be listed? This doesn't make sense to me honestly. Where is the specification for this? Wouldn't it be sufficient to display a warning instead of an error here? Is this configurable? Where is the "Discover annotated classes automatically" option for my existing web project? Note by "configurable" in meant a setting in the form error, warning, or ignore for these classes. Sorry, found "Discover annotated classes automatically" under Project -> Properties -> Java Persistence (In reply to comment #2) > I didn't know THAT. So, when using @IdClass mappings the ID class doesn't have > to be listed and when using @EmbeddedId the ID class must be listed? This > doesn't make sense to me honestly. > > Where is the specification for this? From the JPA 2.0 spec: 8.2.1.6 mapping-file, jar-file, class, exclude-unlisted-classes The following classes must be implicitly or explicitly denoted as managed persistence classes to be included within a persistence unit: entity classes; embeddable classes; mapped superclasses. That said, as Paul mentioned, whether this listing is required is up to the user (based on their config), and this can be set in the project properties on the JPA node or during project creation. Explicitly listing classes is not required in most configurations, but is the default as it guarantees that your classes will be managed at runtime. (In reply to comment #3) > Wouldn't it be sufficient to display a warning instead of an error here? Is > this configurable? Yes, this is configurable at the workspace or project level. See the Java Persistence->JPA/JPA -> Error/Warnings->Persistence Unit settings. (In reply to comment #3) > Wouldn't it be sufficient to display a warning instead of an error here? Is > this configurable? It's debatable. In general we've tried to make things errors that will fail at runtime, and warnings if it's "generally not a good idea". At least in the reference implementation, this scenario will fail at runtime. |
Build Identifier: 20100617-1415 The following @EmbeddedId mappings result in incorrect validation: [code]@Entity @Table(name = "Groups") @Name(value = "group") public class Group implements Serializable { @EmbeddedId private GroupId embeddedId; ... } [/code] [code]@Embeddable public class GroupId implements Serializable { @Column(name = "round_id") private Integer roundId; @Column(name = "ordinal_nbr") private Integer ordinalNbr = 1; ... } [/code] The Group class has two columns, both being PK columns. Dali shows an error "Class GroupId is mapped, but is not included in any persistence unit" The respective @IdClass mappings work in Dali without problems. Note, this error only occurrs with @EmbeddedId mappings. The problem here seems to be the @Embeddable on the ID class. Removing it removes the Dali error. However, it's not correct to remove the @Embeddable. See here to confirm that the above mappings should be correct: http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Embedded_Id Reproducible: Always Steps to Reproduce: 1. Take any @EmbeddedId - ID class mappings (including @Embeddable) 2. Validate 3.