Announcement Announcement Module
Collapse
No announcement yet.
Inheritance with Rowmapper Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inheritance with Rowmapper

    Hi,

    We are using jdbcTemplate in our DAO classes and not using an ORM.
    I am interested in knowing what is the best way to update attributes of a parent object using the rowMapper.
    If class B extends A, I could write B.setMethodOnClassA, and it should work as long as the column is in the resultset and throw an error otherwise.

    What is the best way to achieve this hierarchical mapping?

    Thanks
    Sanjay

  • #2
    Originally posted by sanjaysood View Post
    Hi,

    We are using jdbcTemplate in our DAO classes and not using an ORM.
    I am interested in knowing what is the best way to update attributes of a parent object using the rowMapper.
    If class B extends A, I could write B.setMethodOnClassA, and it should work as long as the column is in the resultset and throw an error otherwise.

    What is the best way to achieve this hierarchical mapping?

    Thanks
    Sanjay
    Just to clarify this a bit further. I have Node class and a FileNode class that is derived from the Node class.
    I have a FileNodeRowMapper with all the attributes of the FileNode class. I have a NodeRowMapper with all the attributes of the Node class. The underlying mySql databse tables are Filetable & LinkTable which are mapped to FileNode and Node respectively. When I do an update to the FileNode object I need to update some of the attributes of the Node object, the parent class as well.
    I have a query with the join to retrieve all the data needed, which are multiple rows stored in a List<FileNode> object. I could include these additional columns/attributes in the FileNodeRowMapper, which seem to work for the SQL queries which have those columns and failing for those simpler ones, which do not have those columns in the resultset, which use the same FileNodeRowMapper. Not sure if this is the way to accomplish this by expanding the scope of other queries and expecting a cleaner mechanism here.
    Can some one please advise based on their experience of how best to handle this scenario?

    Thanks for your help.

    Comment

    Working...
    X