[Java] [ibatis] How to get records of 1-to-N relationship with List <Map <>>

That is this. The point is the groupBy attribute of resultMap = "A0160Plus"

◆SQLMap

<resultMap id="A0162ResultMapPlus" class="java.util.HashMap"							
	groupBy="A0162_NO">						
	<result column="SEIRINO" property="A0162_SEIRINO" />						
	<result column="BUYER_NO" property="A0162_BUYER_NO" />						
	<result column="A0162_NO" property="A0162_NO" />						
	<result column="A0162_NAME" property="A0162_NAME" />						
</resultMap>							
<resultMap id="A0164ResultMapPlus" class="java.util.HashMap"							
	groupBy="A0164_NO">						
	<result column="SEIRINO" property="A0164_SEIRINO" />						
	<result column="BUYER_NO" property="A0164_BUYER_NO" />						
	<result column="A0164_NO" property="A0164_NO" />						
	<result column="A0164_NAME" property="A0164_NAME" />						
</resultMap>							
<resultMap id="A0168ResultMapPlus" class="java.util.HashMap"							
	groupBy="A0168_NO">						
	<result column="SEIRINO" property="A0168_SEIRINO" />						
	<result column="BUYER_NO" property="A0168_BUYER_NO" />						
	<result column="A0168_NO" property="A0168_NO" />						
	<result column="A0168_NAME" property="A0168_NAME" />						
</resultMap>							
<resultMap id="A0160Plus" class="java.util.HashMap" groupBy="SEIRINO,BUYER_NO">							
	<result column="SEIRINO" property="SEIRINO" />						
	<result column="BUYER_NO" property="BUYER_NO" />						
	<result column="BUYER_NAME" property="BUYER_NAME" />						
	<result property="A0162" resultMap="user.A0162ResultMapPlus"						
		javaType="java.util.ArrayList" />					
	<result property="A0164" resultMap="user.A0164ResultMapPlus"						
		javaType="java.util.ArrayList" />					
	<result property="A0168" resultMap="user.A0168ResultMapPlus"						
		javaType="java.util.ArrayList" />					
</resultMap>							
<select id="getA0160Plus" resultMap="A0160Plus" parameterClass="Map">							
	select						
	c.seiriNo, c.buyer_no as buyer_no,c.buyer_name as buyer_name, 						
	o.seiriNo as A0162_SEIRINO, o.buyer_no as A0162_BUYER_NO,o.A0162_no as						
	A0162_NO,o.A0162_name as A0162_NAME, 						
	a.seiriNo as						
	A0164_SEIRINO,a.buyer_no as A0164_BUYER_NO, a.A0164_no as						
	A0164_NO,a.A0164_name as A0164_NAME ,						
	b.seiriNo as A0168_SEIRINO,b.buyer_no as A0168_BUYER_NO, b.A0168_no as						
	A0168_NO,b.A0168_name as A0168_NAME						
	from						
	((A0160z c 						
	left outer 						
	join						
	A0162 o on c.SEIRINO = o.SEIRINO and						
	c.buyer_no = o.buyer_no) 						
	left						
	outer 						
	join  A0164 a on o.SEIRINO =						
	a.SEIRINO and o.buyer_no =						
	a.buyer_no )						
	left outer						
	join  A0168 b on						
	c.SEIRINO = b.SEIRINO and c.buyer_no = b.buyer_no						
	order by c.SEIRINO ,						
	c.BUYER_NO,o.A0162_no,a.A0164_no,b.A0168_no						
							
</select>							

◆ java side

・ List <Map <String, Object >> ListmapPlus = queryDAO.executeForObjectList("user.getA0160Plus", null);

Recommended Posts

[Java] [ibatis] How to get records of 1-to-N relationship with List <Map <>>
[Java] Convert 1-to-N List to Map
[Java] How to get the authority of the folder
[Java] How to get the URL of the transition source
[Java] How to get the maximum value of HashMap
As of April 2018 How to get Java 8 on Mac
I want to get along with Map [Java beginner]
[Java] How to use Map
[Java] How to use Map
An unsupported Java version How to get rid of errors
How to use trained model of tensorflow2.0 with Kotlin / Java
For Java beginners: List, Map, Iterator / Array ... How to convert?
How to use Java HttpClient (Get)
How to get started with slim
[Java] How to use List [ArrayList]
How to get along with Rails
Java8 list conversion with Stream map
How to get the contents of Map using for statement Memorandum
How to get the length of an audio file in java
How to increment the value of Map in one line in Java
How to compile Java with VsCode & Ant
[Java] How to compare with equals method
[java] Summary of how to handle char
[Java] How to add data to List (add, addAll)
[Note] How to get started with Rspec
[Java] [Maven3] Summary of how to use Maven3
How to sort the List of SelectItem
How to get the date in java
Get a list of S3 files with ListObjectsV2Request (AWS SDK for Java)
[Java] How to get to the front of a specific string using the String class
How to get the absolute path of a directory running in Java
How to get Excel sheet name list in Java (POI vs SAX)
[Java] How to test for null with JUnit
[java] Summary of how to handle character strings
[Java] How to get and output standard input
[Java] Summary of how to abbreviate lambda expressions
How to get the ID of a user authenticated with Firebase in Swift
How to get today's day of the week
[Java] How to easily get the longest character string of ArrayList using stream
How to get started with Eclipse Micro Profile
[Java] How to get random numbers excluding specific numbers
How to get and study java SE8 Gold
How to get resource files out with spring-boot
[Java] How to get the redirected final URL
[Java] How to operate List using Stream API
[Java] How to get the key and value stored in Map by iterative processing
How to get the class name of the argument of LoggerFactory.getLogger when using SLF4J in Java
How to save a file with the specified extension under the directory specified in Java to the list
Summary of how to use the proxy set in IE when connecting with Java
[Java] How to use compareTo method of Date class
How to call functions in bulk with Java reflection
List processing to understand with pictures --java8 stream / javaslang-
Get a list of MBean information for Java applications
How to write Scala from the perspective of Java
[Java] Types of comments and how to write them
[Java] How to omit spring constructor injection with Lombok
java: How to write a generic type list [Note]
[Java] How to encrypt with AES encryption with standard library
[Java] How to get a request by HTTP communication
[Java] Get the file path in the folder with List
Summary of Java communication API (1) How to use Socket