48.11. 8. OneToMany


@OneToMany 주석의 용도는 List<?& gt; 필드를 사용하여 DestinationRule 클래스를 정의하거나 반복적인 그룹을 포함하는 레코드에서 작업할 수 있도록 허용하기 위한 것입니다.

*Restrictions OneToMany*
Copy to Clipboard Toggle word wrap

주의, 많은 바인딩에 대 한 것은 계층 구조의 여러 수준에서 정의 된 반복을 처리 할 수 없습니다.

관련 OneToMany WORKS in the following cases:

  • 반복적인 그룹이 포함된 FIX 메시지 읽기(= 태그/키 그룹)
  • 반복적인 데이터를 사용하여 CSV 생성
Expand
주석 이름레코드 유형level

OneToMany

all

속성

Expand
매개변수 이름type정보

mappedTo

string

선택 사항 - 문자열 - 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
Copy to Clipboard Toggle word wrap

Remark : 반복되는 데이터는 도서의 제목과 게시 날짜에 관련된 반면, 첫 번째, 마지막 이름 및 기간이 일반적입니다.

그리고 이 작업을 수행하는 데 사용되는 클래스는 다음과 같습니다. 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;
}
Copy to Clipboard Toggle word wrap

매우 간단한되지 않습니다.!

사례 2: 태그/키 그룹이 포함된 FIX 메시지 읽기

다음은 당사의 모델에서 처리하는 메시지입니다.

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 Clipboard Toggle word wrap

태그 22, 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;
}
Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat