을 받고 entityManageFactory 오류가 있습니다. 키마 검증:다[hibernate_sequence]

0

질문

저는 2 데이터베이스가 있습니다. 중 하나가 설정하고 그것은 작동합니다. 후에 추가 두 번째 db 나는 다음과 같은 오류 entityManageFactory 오류가 있습니다. 키마 검증:다[hibernate_sequence].

Db 스키마 다음과 같습니다:db 스키마 스크린샷

enter image description here

나는 두 개의 클래스 두 테이블:

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity(name = "nightly_rate_amounts")
@Table(name = "nightly_rate_amounts")
public class BookedNightlyRate {
@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "bnr_meta_id")
    private Long id;
    @Column(name = "unit_uuid")
    private UUID unitUuid;
    private LocalDate firstLiveDate;
    private LocalDate date;
    private BigDecimal amount;
    @Column(name = "currency_code")
    private String currencyCode;

    public ImmutableTriple<UUID, LocalDate, String> toUnitDateCurrencyKey() {
        return new ImmutableTriple<>(unitUuid, date, currencyCode);
    }

    public ImmutablePair<UUID, String> toUnitCurrencyKey() {
        return new ImmutablePair<>(unitUuid, currencyCode);
    }
}

고:

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity(name = "unit_attributes")
@Table(name = "unit_attributes")
public class BookedUnitAttributes {
    @Id
    @Column(name = "unit_uuid")
    private UUID unitUuid;
    @Column(name = "first_date_available")
    private LocalDate firstLiveDate;
}

과 파일을 저장소:

public interface BookedNightlyRatesDao extends CrudRepository<BookedNightlyRate, Long> {

@Query(value = "SELECT DISTINCT bnr.unit_uuid as unitUuid, bnr.date, bnr.amount, bnr.currency_code as currencyCode " +
        "FROM nightly_rate_amounts AS bnr " +
        "WHERE bnr.unit_uuid IN (<unitUuids>) AND (bnr.date BETWEEN :fromDate AND :toDate)", nativeQuery = true)
List<BookedNightlyRate> findBookedNightlyRates(@Param("unitUuids") List<String> unitUuids, @Param("fromDate") LocalDate fromDate, @Param("toDate") LocalDate toDate);

@Query(value = "SELECT DISTINCT opb.unit_uuid as unitUuid, opb.date, opb.amount, opb.currency_code as currencyCode " +
        "FROM opb_nightly_rate_amounts AS opb " +
        "JOIN opb_sync_enabled_for_unit AS sync ON opb.unit_uuid = sync.unit_uuid WHERE sync.enabled = 1 AND opb.is_active = 1 " +
        "AND sync.unit_uuid IN (<unitUuids>) AND (opb.date BETWEEN :fromDate AND :toDate)", nativeQuery = true)
List<BookedNightlyRate> findOPBRates(@Param("unitUuids") List<String> unitUuids, @Param("fromDate") LocalDate fromDate, @Param("toDate") LocalDate toDate);
}

두 번째 인터페이스::

public interface BookedUnitAttributesDao extends CrudRepository<BookedUnitAttributes, UUID> {

@Query(value = "SELECT ua.unit_uuid as unitUuid, ua.first_date_available as firstLiveDate " +
        "FROM unit_attributes AS ua " +
        "WHERE ua.unit_uuid IN (<unitUuids>)", nativeQuery = true)
List<BookedUnitAttributes> findUnitAttributes(@Param("unitUuids") List<String> unitUuids);
}

나는 다시 쓰기 내에서 db jdbi 을 jpa. 그래서 데이터 수업이 없고 주석하고 나 refactor 내 모델 파일에 대한 쿼리에서 저장소의 파일이 있습니다.

hibernate java spring spring-data-jpa
2021-11-23 06:49:58
1

최고의 응답

0

이후 두 개 추가 데이터베이스천 리뷰 알고 어떤 종류의 데이터베이스에 그것을 연결합니다. 당신이 정확히 보여주는 어떤 종류의 당신이 원하는 데이터베이스를 연결합니다. 수도 있습 confiugure 연결을 가진 두 개의 서로 다른 데이터베이스에 여기를 들어 작업의 JdbcTemplate 연결합니다.

@Configuration
@ComponentScan("uz.dbo.dbocallcenter")
@PropertySource("classpath:database.properties")
public class Config2 {

    @Autowired
    Environment environment;

    private final String DRIVER = "driver";
    private final String URL1 = "url1";
    private final String USER1 = "dbusername1";
    private final String PASSWORD1 = "dbpassword1";
    private final String URL2 = "url2";
    private final String USER2 = "dbusername2";
    private final String PASSWORD2 = "dbpassword2";


    private DataSource dataSource1() {
        return getDataSource(URL1, USER1, PASSWORD1);
    }
    private DataSource dataSource2() {
        return getDataSource(URL2, USER2, PASSWORD2);
    }

    private DataSource getDataSource(String url1, String user1, String password1) {
        DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
        driverManagerDataSource.setUrl(environment.getProperty(url1));
        driverManagerDataSource.setUsername(environment.getProperty(user1));
        driverManagerDataSource.setPassword(environment.getProperty(password1));
        driverManagerDataSource.setDriverClassName(environment.getProperty(DRIVER));
        return driverManagerDataSource;
    }




    @Bean(name = "jdbcTemplate2")
    public JdbcTemplate jdbcTemplate2() {
        return new JdbcTemplate(dataSource2());
    }
    @Bean(name = "jdbcTemplate1")
    public JdbcTemplate jdbcTemplate1() {
        return new JdbcTemplate(dataSource1());
    }

}

당신이해야 할로 JpaRepository 연결합니다. 더 정확하게 당신을 얻을 수 있습에 대한 지식이 원

https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#reference

여기에 또한 좋은 설명하는 방법을 연결하는 두 개의 전혀 다른 데이터베이스에서나 봄 부팅 프로젝트

https://www.baeldung.com/spring-data-jpa-multiple-databases

2021-11-23 10:37:58

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................