Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 134811

Summary: "Sequence generator "null" cannot be resolved" error
Product: [WebTools] Dali JPA Tools Reporter: Kevin Sutter <kwsutter>
Component: FrameworkAssignee: Karen Butzke <karenfbutzke>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: kwsutter
Version: 0.5   
Target Milestone: 0.5 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Kevin Sutter CLA 2006-04-04 13:06:07 EDT
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.
Comment 1 Kevin Sutter CLA 2006-04-12 12:30:16 EDT
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;
	}
Comment 2 Karen Butzke CLA 2006-05-11 18:14:50 EDT
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?
Comment 3 Kevin Sutter CLA 2006-05-18 12:22:39 EDT
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
Comment 4 Karen Butzke CLA 2006-05-31 13:14:54 EDT
Fixed for the M4 milestone, primary key generation has been reworked
Comment 5 Neil Hauge CLA 2007-03-14 18:19:34 EDT
Closing Verified Fixed bugs from 0.5.