Results 1 to 5 of 5

Thread: Annotation driven row mapping?

  1. #1
    Join Date
    May 2007
    Location
    Brisbane, Australia
    Posts
    97

    Default Annotation driven row mapping?

    Has there been any discussion about using annotations to reduce the verbosity of managing row mappers?

    So that for example,

    Code:
    @RowMapper(name = fooMapper)
    private Foo mapRow(ResultSet rs, int rowNum)();
    is equivalent to

    Code:
    private ParameterizedRowMapper<Foo> fooMapper = new ParameterizedRowMapper<Foo>(){}
    It's something that would be nice to have so that my DAO test code (which uses Spring's Transactional Context Tests will not have about half a dozen inner classes (some about 3 deep) for unwinding my object tree.

  2. #2
    Join Date
    Oct 2008
    Location
    Delhi, India
    Posts
    163

    Default

    Seconded. I have the same problem, some DAO classes were unmanagable due to the mappers etc they contain, I have now moved almost all mappers to seperate classes in a seperate package to reduce code clutter. The annotated way would help clean up code so much.

  3. #3
    Join Date
    May 2007
    Location
    Brisbane, Australia
    Posts
    97

    Default

    Looks like hibernate does something similar:
    Code:
    @org.hibernate.annotations.MapKey( columns = { @Column( name="my_enum" ) } )

  4. #4
    Join Date
    Oct 2008
    Location
    Delhi, India
    Posts
    163

    Default

    Quote Originally Posted by tunaranch View Post
    Looks like hibernate does something similar:
    Code:
    @org.hibernate.annotations.MapKey( columns = { @Column( name="my_enum" ) } )
    As much as I may approve of hibernate, there are some cases where you just can't use it. Escpecially those where you are 'asked' not too. There is little someone like me can do about it. In such cases I have to rely on Jdbc DAO's for my data access.

  5. #5
    Join Date
    May 2007
    Location
    Brisbane, Australia
    Posts
    97

    Default

    Not advocating the use of Hibernate. Merely illustrating how the annotation makes the code look simpler.

Tags for this Thread

Posting Permissions

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