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.