| Author |
Message |
|
|
Post subject: Oracle Sequence creation trouble
Posted: Mar 15, 2010 - 07:56 PM
|
|
Registered Member


Joined: May 01, 2006
Posts: 15
|
|
While scaffolding a new project, I do not see an option to create an oralce sequence as part of the entity.
I tried adding it to the following file, but it doesn't seem to like what I am trying to annotate.
in Guideline.java
| Code: | @Column(name = "ID", nullable = false)
@Basic(fetch = FetchType.EAGER)
@Id
@XmlElement
@GeneratedValue(generator = "GuidelineSeq", strategy = GenerationType.SEQUENCE)
@SequenceGenerator(name = "GuidelineSeq", sequenceName = "seq_guideline_id", allocationSize = 1)
Integer id; |
The sequence doesn't get read or invoked at all by the system.
Any ideas ?
Thanks,
Jamie |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Oracle Sequence creation trouble
Posted: Mar 16, 2010 - 01:07 PM
|
|

Joined: Jan 20, 2010
Posts: 191
|
|
Hi Jamie,
MyEclipse for Spring does not currently have an editor UI for identity / sequence generators / auto increment capability, but please don't hesitate to vote for this JIRA feature request at https://www.skywayperspectives.org/jira/browse/MOD-1287
Regarding the code, this seems to be a Hibernate JPA Oracle question. I tried on my application locally and couldn't get it to work either, so I'd definitely welcome any Hibernate JPA Oracle Spring experts to the table. One thing to note, is the generated DO has an Identity class, so I'm assuming that has some impact.
I do see a couple alternatives:
1. Create a trigger on NULL entries, explained here http://www.oracle-base.com/articles/misc/AutoNumber.php
2. Create a Named Query or direct query that uses the [SEQ NAME].NEXTVAL
-Dave |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Oracle Sequence creation trouble
Posted: Mar 16, 2010 - 02:19 PM
|
|

Joined: Jan 20, 2010
Posts: 191
|
|
Well, one assumption was correct...
I was able to get this to work, only if I removed the @IdClass annotation on the Domain Object.
As to what impact the @IdClass has on generators and how to get sequences to work within the IdClass annotation, I'll have to revert to more research. But for now, this should hopefully get you most of the way there...
-Dave |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Oracle Sequence creation trouble
Posted: Mar 16, 2010 - 02:50 PM
|
|

Joined: Jan 20, 2010
Posts: 191
|
|
|
|
|
 |
|
|
Post subject: RE: Oracle Sequence creation trouble
Posted: Mar 16, 2010 - 03:27 PM
|
|
Registered Member


Joined: May 01, 2006
Posts: 15
|
|
Dave,
I found that removing the IdClass causes the sequence to work as desires.
Another thing I have found is that if you place this annotation at the top of the file, then rebuild the artifacts, or clean the project -- your code gets whacked.
If you place it near the variable instead of at the @Entity annotation, the code will be kept during a clean.
Is there a way to request that custom Annotations be spared by the clean etc....
Thanks,
Jamie |
|
|
| |
|
|
|
 |
|
|