I have small job reading data from file and writing data to DB using hibernate.
I my database I have table USER and dictionary UserType.
CREATE TABLE `user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL ,
`UserType_id` bigint(20) NOT NULL ,
...
PRIMARY KEY (`id`)
)
CREATE TABLE `UserType` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`typename` varchar(50) NOT NULL ,
PRIMARY KEY (`id`)
)
UserType table contains more less 20 record.
In my file i have records:
username;...;typename
Field typename is string referes to typename column of UserType table.
My question is :
What should I do to read usertype NAME from file and insert usertype ID ito UserType_id column of user tble in hibernate writer ?
Which annotation should I use in my User class to achieve this ?
Do I need any bean configuration ?


Reply With Quote