Results 1 to 2 of 2

Thread: Small hibernate problem.

Hybrid View

  1. #1

    Default Spring batch dictionaries in hibernate writer

    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 at 10:46 AM.

  2. #2

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •