2014-04-09 2 views
1
I는 다음의 구조를 갖는 스프링 및 만약 angel와 받는다는 모듈 프로젝트 개발있어

병합 다른 지속성 부

|-- parent 
`-- pom.xml 
    |-- model1 
    | `-- pom.xml 
    |-- model2 
     -- pom.xml 
    |-- services 
     -- pom.xml 
    |-- web-app 
     -- pom.xml 

모델 1과 모델 2는 I이 방법으로 변성 두 받는다는 - 원형 - 빠른있다

|-- model1 
    |--src 
     |--main 
      |--java 
     |--main 
      |--resources 
       |-- META-INF 
        -- persistence.xml 

|-- model2 
    |--src 
     |--main 
      |--java 
     |--main 
      |--resources 
       |-- META-INF 
        -- persistence.xml 

는 더욱이 MODEL2 치어의 I이 종속성

<dependency> 
     <groupId>it.mycompany</groupId> 
     <artifactId>model1</artifactId> 
     <version>0.0.1-SNAPSHOT</version> 
    </dependency> 

지속성을 갖고 파일은 이제

persistence> 
<persistence-unit name="model2Unit"> 

    <class>it.mycompany.Agreement</class> 
    <class>it.mycompany.AgreementDetail</class> 

    // and more others 

</persistence-unit> 

내 문제가 persistence.xml을

<persistence> 
<persistence-unit name="model1Unit"> 

    <class>it.mycompany.User</class> 
    <class>it.mycompany.UserDetail</class> 
    <class>it.mycompany.Address</class> 
    <class>it.mycompany.Agent</class> 
    <class>it.mycompany.Agency</class> 

    // and more others 

</persistence-unit> 

모델 2의 persistence.xml

MODEL1 다음과 같은 방법으로 정의되는 매핑 내 model2 프로젝트 다음 작업을 수행하고 싶습니다.

@Entity 
    public class Agreement{ 

    @Id 
    @GeneratedValue 
    private long id; 

    private String description; 

    @ManyToOne 
    private Agent agent; 

} 

하지만 에이전트 엔티티는 model1 프로젝트/데이터 소스에 포함되어 있습니다. 사실 model2 프로젝트에서 model1 프로젝트의 일부 엔티티를 사용하여 을 다시 작성하지 않으려합니다.

이것이 가능합니까? 제안 사항이 있으십니까?

+0

항목 (테이블)을 이용하여 해결할 다른 두 개의 DB에 속하는? – Suvasis

+0

예 테이블이 서로 다른 두 개의 DB에 속해 있습니다. – Skizzo

+0

계약 및 에이전트가 서로 다른 두 개의 DB에 속해 있다면 논리적/물리적으로 서로 매핑됩니다. DB에서 그들 사이의 관계는 어떻게 존재합니까? 기본적으로 @ManyToOne을 사용하면서 어떤 관계가 종료되는지 알고 싶습니다. – Suvasis

답변

0

Model2 persistence.xml의 엔티티가 들어있는 jar를 다시 만들지 않고 가져올 수 있습니다.

<jar-file>Model_1_Entity.jar</jar-file>