Community
Participate
Working Groups
I am working with Milestone 1, Iteration 2 drop of Dali. I posted several observations to the forum. Some of the observations were requested to be turned into bug reports. The Persistence Properties seems to have a problem with any value for the GenerationType other than Auto. I am now getting the following error when the GenerationType is either Sequence or Table. I have specified the required name field, but I still get the following error (sorry for the formatting). Severity Description Resource In Folder Location Creation Time Id 2 Sequence generator "null" cannot be resolved Address.java jpa.dali/src/com/ibm/ws/persistence/dali line 46 March 22, 2006 11:07:35 AM 16315 Karen could not reproduce the problem. I figured out that I have to have an active connection to the database (derby, in my case) for this error to occur. If I do not have an active connection to the database, then I have no problems with the various values for the GenerationType. But, if I have an active connection to the database, and select Sequence for the GenerationType, and fill in some name for the Sequence Generator, I get the above posted error about not being to resolve a "null" sequence generator. No matter what I enter, I can not work around this problem. Here's a code snippet for my ID... @Id @Column(name="ID") @GeneratedValue(strategy=GenerationType.SEQUENCE) @SequenceGenerator(name="b") private Long id; Let me know if you need more data. Thanks.
Same type of problem exists for Table generation: Severity Description Resource In Folder Location Creation Time Id 2 Table generator "null" cannot be resolved Employee.java jpa.dali/src/com/ibm/ws/persistence/spec/complex line 66 April 12, 2006 8:15:52 AM 20823 Here's the code: @Id @GeneratedValue(strategy=GenerationType.TABLE) @TableGenerator(name="MissingInSpec2") public Integer getId() { return id; } protected void setId(Integer id) { this.id = id; }
I have fixed the problem, if you don't specify a sequence or a table, there will be no error message. If you do specify one, it will check against the database and make sure it exists. Not completely related to the bug: I am under the impression that you need to specify the generator name in the GeneratedValue annotation. If you don't specify it, it will be determined by the provider instead of using the one you've defined. Am I misreading the spec?
Hi, Your reading of the spec sounds accurate. If you do not specify a generator name, then the persistence provider will need to provide one. But, your earlier statement indicates that you think you *have* to provide a generator name in the @GeneratedValue annotation. I don't think that's accurate. If you don't specify a name, the persistence provider will generate a name for you. Given that, I don't think the fix for this defect is quite complete. If I only have the following code and annotations: @Id @GeneratedValue(strategy=GenerationType.TABLE) public Integer getId() { return projId; } protected void setId(Integer id) { this.projId = id; } I get an error that is very similar (although not identical) to the original one posted for this bug report: "Generator name "null" not defined" If I modify this code to put a TableGenerator annotation, then the error messages go away. @Id @GeneratedValue(strategy=GenerationType.TABLE) @TableGenerator(name="MissingInSpec") public Integer getId() { return projId; } protected void setId(Integer id) { this.projId = id; } But, this is kind of strange because I still have not provided a generator name in the GeneratedValue annotation. I provided the TableGenerator annotation, but nobody is "linking" to it. So, I don't know if this bug is completely resolved yet. What do you think? Thanks, Kevin
Fixed for the M4 milestone, primary key generation has been reworked
Closing Verified Fixed bugs from 0.5.