Forums Register Login

how to hbm.xml

+Pie Number of slices to send: Send
hi all,
i have very basic problem regarding hibernate.the following is DDL of the table which i want to map to class.

CREATE TABLE `corporate_levels_history` (
`corporate_level_id` int(10) unsigned NOT NULL,
`corporate_level_code` int(10) unsigned NOT NULL,
`corporate_level_name` varchar(45) NOT NULL,
`corporate_level_description` varchar(500) NOT NULL,
`modified_by` varchar(45) NOT NULL,
`modified_on` datetime NOT NULL,
`approval_status` varchar(2) NOT NULL,
`remark` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

you can see above table does not have primary key.

can any one tell me what will be the hbm.xml contents?

please help me. thanks in advance.

thanks,
-Pankaj
+Pie Number of slices to send: Send
 


you can see above table does not have primary key.


First and foremost, I'd fix that. Entities without primary keys cannot be considered relational data (since without a unique identifier they can't participate in relationships) so using a Object-Relational Mapping tool with such data is difficult.

If you can't change the DDL then your only option is to map all the fields in the table as one big composite key.
+Pie Number of slices to send: Send
Hi,
If you are using oracle as your database you can use the oracle generated rowid as your primary key. Hibernate provides support for the rowid. In this scenario you might not require a primary key.
This solution will work only if you are going to use this table for fetching the data. For inserting data you might have to use a composite key as Paul suggested.

Ketan.
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2501 times.
Similar Threads
Problem displaying report using JSP
Hibernate and Composite Foreign Keys
problem in creating table with FULLTEXT KEY index
How toPersist Value in the Tables Using Entity Bean
setBoolean - not working properly
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:14:42.