주석 @OneToMany 의 용도는 List<? > 필드에서 POJO 클래스를 정의하거나 반복적인 그룹을 포함하는 레코드에서 작업할 수 있도록 하는 것입니다.
참고
OneToMany 에 대한 제한사항은 여러 수준의 계층 구조에 정의된 반복을 처리할 수 없습니다.
다음 경우 관련 OneToMany ONLY WORKS:
반복적인 그룹(= 태그/키 그룹)이 포함된 FIX 메시지 읽기
반복적인 데이터로 CSV 생성
Expand
주석 이름
레코드 유형
level
OneToMany
all
속성
Expand
매개변수 이름
유형
필수 항목
기본값
정보
mappedTo
문자열
클래스의 Type에 연결된 클래스 이름입니다.Class name associated to the type of the List<Type of the Class>
케이스 1 : 반복적인 데이터로 CSV 생성
다음은 우리가 원하는 CSV 출력입니다.
Claus,Ibsen,Camel in Action 1,2010,35
Claus,Ibsen,Camel in Action 2,2012,35
Claus,Ibsen,Camel in Action 3,2013,35
Claus,Ibsen,Camel in Action 4,2014,35
Claus,Ibsen,Camel in Action 1,2010,35
Claus,Ibsen,Camel in Action 2,2012,35
Claus,Ibsen,Camel in Action 3,2013,35
Claus,Ibsen,Camel in Action 4,2014,35
Copy to ClipboardCopied!Toggle word wrapToggle overflow
참고
반복적인 데이터는 책의 제목과 그 발행일의 제목과 첫 번째, 마지막 이름과 나이는 일반적이며 이 데이터를 모델링하는 데 사용되는 클래스입니다. Author 클래스에는 도서 목록이 포함되어 있습니다.
반복적인 데이터로 CSV 생성
@CsvRecord(separator=",")
public class Author {
@DataField(pos = 1)
private String firstName;
@DataField(pos = 2)
private String lastName;
@OneToMany
private List<Book> books;
@DataField(pos = 5)
private String Age;
}
public class Book {
@DataField(pos = 3)
private String title;
@DataField(pos = 4)
private String year;
}
@CsvRecord(separator=",")
public class Author {
@DataField(pos = 1)
private String firstName;
@DataField(pos = 2)
private String lastName;
@OneToMany
private List<Book> books;
@DataField(pos = 5)
private String Age;
}
public class Book {
@DataField(pos = 3)
private String title;
@DataField(pos = 4)
private String year;
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow
케이스 2 : 태그/키 그룹이 포함된 FIX 메시지 읽기
다음은 우리 모델에서 처리하려는 메시지입니다.Here is the message that we want to process in our model:
8=FIX 4.19=2034=135=049=INVMGR56=BRKR
1=BE.CHM.00111=CHM0001-0158=this is a camel - bindy test
22=448=BE000124567854=1
22=548=BE000987654354=2
22=648=BE000999999954=3
10=220
8=FIX 4.19=2034=135=049=INVMGR56=BRKR
1=BE.CHM.00111=CHM0001-0158=this is a camel - bindy test
22=448=BE000124567854=1
22=548=BE000987654354=2
22=648=BE000999999954=3
10=220
Copy to ClipboardCopied!Toggle word wrapToggle overflow
태그(2, 48 및 54)가 반복됩니다.
그리고 코드:
태그/키 그룹이 포함된 FIX 메시지 읽기
public class Order {
@Link Header header;
@Link Trailer trailer;
@KeyValuePairField(tag = 1) // Client reference
private String account;
@KeyValuePairField(tag = 11) // Order reference
private String clOrdId;
@KeyValuePairField(tag = 58) // Free text
private String text;
@OneToMany(mappedTo = "org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Security")
List<Security> securities;
}
public class Security {
@KeyValuePairField(tag = 22) // Fund ID type (Sedol, ISIN, ...)
private String idSource;
@KeyValuePairField(tag = 48) // Fund code
private String securityCode;
@KeyValuePairField(tag = 54) // Movement type ( 1 = Buy, 2 = sell)
private String side;
}
public class Order {
@Link Header header;
@Link Trailer trailer;
@KeyValuePairField(tag = 1) // Client reference
private String account;
@KeyValuePairField(tag = 11) // Order reference
private String clOrdId;
@KeyValuePairField(tag = 58) // Free text
private String text;
@OneToMany(mappedTo = "org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Security")
List<Security> securities;
}
public class Security {
@KeyValuePairField(tag = 22) // Fund ID type (Sedol, ISIN, ...)
private String idSource;
@KeyValuePairField(tag = 48) // Fund code
private String securityCode;
@KeyValuePairField(tag = 54) // Movement type ( 1 = Buy, 2 = sell)
private String side;
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow