Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6354069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:31:01+00:00 2026-05-24T22:31:01+00:00

I’m in the process of creating a front end for a Database Driven application

  • 0

I’m in the process of creating a front end for a Database Driven application and Could do with some advice. I have the following basic entities in my database:

  • aspect
  • aspect_value

As you can image I can have many aspect value to each aspect so that when a user records an aspect they can select more than one value per aspect… simple.

I’ve created an POJO entity to model each aspect an my question is this… using Spring and the jdbcTemplate how would I be able to create the desired composite relationship using org.springframework.jdbc.core.RowMapper i.e. each aspect object containing one or more aspect value ojects? And for that matter I would appreciate if you could please let me know if this would be the best way to do it. I’m keen at some point to delve deeper into ORM but I’ve been put off so far by the number of issues I’ve encountered which has slowed down my development and led to the decision to use jdbcTemplate instead.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:31:02+00:00Added an answer on May 24, 2026 at 10:31 pm

    You can use a RowMapper if you are storing aspect_values in your aspect object as objects. Each call to RowMapper returns an object so you’ll end up with a collection of aspect_values. If you need to build an aspect object (or objects) with values contained in the aspect_value table then a ResultSetExtractor is the better choice.

    Here are my examples as promised. I have to type these in by hand because our development network is on an internal network only so any typos are copy errors and not errors in the code. These are abbreviated versions of inner classes in my DAO:

    This maps a single row in the ResultSet to an object:

    public List<MessageSummary> getMessages(Object[] params)
    {
      // mList is filled with objects created in MessageRowMapper,
      // so the length of the list equal to the number of rows in the ResultSet
      List<MessageSummary> mList = jdbcTemplate.query(sqlStr, new MessageRowMapper(),
                                                      params);
      return mList;
    }
    
    private final class MessageRowMapper implements RowMapper<MessageSummary>
    {
      @Override
      public MessageSummary mapRow(ResultSet rs, int i) throws SQLException
      {
        MessageSummary ms = new MessageSummary();
    
        ms.setId(rs.getInt("id"));
        ms.setMessage(rs.getString("message"));
    
        return ms;
      }
    }
    

    ResultSetExtractor works on the same idea except you map the entire set yourself instead of just converting a row into an object. This is useful when your object has attributes from multiple rows.

    public Map<Integer, List<String>> getResults(Object[] params)
    {
      Map<Integer, List<String>> result = jdbcTemplate.query(sqlStr, new ResultExtractor(),
                                                             params);
      return result;
    }
    
    private final class ResultExtractor implements ResultSetExtractor<Map<Integer, List<String>>>
    {
      @Override
      public Map<Integer, List<String>> extractData(ResultSet rs)
                                        throws SQLException, DataAccessException
      {
        Map<Integer, List<String>> resultMap = new HashMap<Integer, List<String>>();
    
        while (rs.next())
        {
          int id = rs.getInt("id");
          List<String> nameList = resultMap.get(id);
          if (nameList == null)
          {
            nameList = new ArrayList<String>();
            resultMap.put(id, nameList);
          }
          nameList.add(rs.getString("name"));
        }
        return resultMap;
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.