Announcement Announcement Module
Collapse
No announcement yet.
Small hibernate problem. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Small hibernate problem.

    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 ?
    Last edited by marcin.kasinski; Aug 16th, 2012, 10:46 AM.

  • #2
    Just use the JDBCTemplate to persist data to your datasource. itemReader reads the file while the itemWriter writes to datasource via JDBCTemplate.

    Have fun,

    Jeff

    Comment

    Working...
    X