ฉันมี 2 ฐานข้อมูล. หนึ่งจะถูกตั้งขึ้นแล้วและมันได้ผล หลังจากที่ฉันเพิ่มสอง db ฉันกำลังจะมีตามข้อผิดพลาด entityManageFactory ข้อผิดพลาด ชุดรูปแบบ-การตรวจสอบ:หายไปโต๊ะ[hibernate_sequence].
ฉัน db รูปแบบชุดสีดูเหมือนนี้:db ชุดรูปแบบภาพหน้าจอที่จับได้
ฉันมีสองชั้นเรียนสำหรับสองตารางข้อมูลเรียบร้อยแล้ว:
@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);
}
ฉัน rewriting ของฉัน db จาก jdbi จะ jpa. ดังนั้นข้อมูลชั้นเรียนไม่มีหมายเหตุประกอบและฉัน refactored ของฉันนางแบบแฟ้มที่เกี่ยวกับมันค้นข้อมูลที่อยู่ในเก็บแฟ้ม