ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Poitras Christian" <Christian.Poit...@ircm.qc.ca>
Subject RE: Problem accessing a HashMap
Date Mon, 10 Sep 2007 14:23:41 GMT
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:spaceman2k4@gmx.de] 
Sent: Monday, 10 September 2007 10:08
To: user-java@ibatis.apache.org
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.


Mime
View raw message