-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Sequential Id Problem
PostPosted: Thu May 22, 2008 4:27 am 
Newbie

Joined: Sun Mar 19, 2006 4:18 pm
Posts: 17
Location: Turkey
Hi,

I am using Hibernate-tools plugin for code generation. I am using "3.2.2 Beta" plugin version. I am generating "Domain Code" and "Dao Code". My db server is Oracle XE.

I want to be signed the id colon as @GeneratedValue(strategy = GenerationType.AUTO). I have created a table, sequence and trigger like these,

Code:
CREATE TABLE CUSTOMER(
    CUSTOMER_ID         NUMBER(38) NOT NULL PRIMARY KEY,
    CUSTOMER_TITLE      VARCHAR2(24) NOT NULL,
    CUSTOMER_NAME       VARCHAR2(40) NOT NULL,
    CUSTOMER_LNAME      VARCHAR2(40) NOT NULL
);

CREATE SEQUENCE CUSTOMER__CUSTOMER_ID START WITH 1 INCREMENT BY 1;

CREATE OR REPLACE TRIGGER AUTO_INC__CUSTOMER_ID
BEFORE INSERT
ON CUSTOMER
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT CUSTOMER__CUSTOMER_ID.NEXTVAL INTO :NEW.CUSTOMER_ID FROM DUAL;
END;


But the code generator is generating entity code like these,

Code:
@Id
@Column(name = "CUSTOMER_ID", unique = true, nullable = false, precision = 38, scale = 0)
public BigDecimal getCustomerId() {
   return this.customerId;
}


So,
Am I missing any thing?

Another question, Can I define specific id generator over another table? The column value will be taken from another table's column value, for example Sequence_Table.

Thanks for your helps.

I have found this info, I have to add sequence info to the hibernate.reveng.xml. After that plugin generating entity code with GeneratedValue anootation. But I cant still generate entity code with TableGenerator annotation.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.