How I can use the key and the value from this map ? Example: HashMap<Object, Integer>
I have to iterate over all elements of the map, but I need the key AND the value ! I need something like this: (#id#,#products.key#,#products.value#) David Poitras Christian wrote: > > It would be easier with a List of Maps. > > Put the information in the Map and plug this kind of code. > <insert id="insertCustomerProductRel" parameterClass="CustomerDTO"> > INSERT INTO PLC.CUSTOMER_PRODUCT_REL (CUSTOMER_ID, > PRODUCT_ID) > VALUES > <iterate property="products" conjunction=","> > > (#id#,#products[].propertyInMap#,#products[].otherPropertyInMap#) > </iterate> > </insert> > > Christian > > > -----Original Message----- > From: PLC_David [mailto:[EMAIL PROTECTED] > Sent: Monday, 10 September 2007 10:08 > To: [email protected] > Subject: Problem accessing a HashMap > > > Originally I had a java.util.List in my Java code to present an > unidirectional one-to-many relation which is a many-to-many relation in > the database. This is a customer that could have multiple products. > Now I need a java.util.HashMap instead of the list where the elements of > the old list are the new keys while the values represent an additional > attribute. The additional value (value of Map) should be saved in a new > column in the existing relation table. > > > The old mapping with list: > > <insert id="insertCustomerProductRel" parameterClass="CustomerDTO"> > INSERT INTO PLC.CUSTOMER_PRODUCT_REL (CUSTOMER_ID, > PRODUCT_ID) > VALUES > <iterate property="products" conjunction=","> > (#id#,#products[].id#) > </iterate> > </insert> > > My question is how I can access the key and the value of this map. So > far I received this exception: > > The error occurred in ibatis/Mapping.xml. > --- The error occurred while preparing the mapped statement for > execution. > --- Check the insertCustomerProductRel. > --- Check the parameter map. > Cause: com.ibatis.sqlmap.client.SqlMapException: ParameterObject or > property was not a Collection, Array or Iterator. > > I hope somebody can help me. > > -- > View this message in context: > http://www.nabble.com/Problem-accessing-a-HashMap-tf4414963.html#a125935 > 47 > Sent from the iBATIS - User - Java mailing list archive at Nabble.com. > > > -- View this message in context: http://www.nabble.com/Problem-accessing-a-HashMap-tf4414963.html#a12596849 Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
