I created a service that connects to two schemas (ex. fo_pgdb, if_pgdb) My issue is when the service queries the table in the if_pgdb schema it looks as though it is querying the table in the fo_pgdb schema. I have checked and hard coded the database URLs in both class attributes (shown in code examples below) look fine. What could be the issue?
example: query on table in fo_pgdb schema is "select * from bid_lines where bidlinseqnumber in (123, 345) returns a result set. because ids 123 and 345 have records in the table.
query on table in if_pgdb schema is "select * from bid_lines where bidlinseqnumber in (567, 8910) returns empty result set. But ids 567 and 8910 those records with those ids are in the table.
test: when I use the ids 123 and 345 in the query on the table in the if_pgdb schema I get the same records that are in the table that are in the fo_pgdb table. That should not happen.
@Configuration
@EnableR2dbcRepositories(entityOperationsRef = "foEntityTemplate", basePackages = "com.r2dbc.poc.repository")
public class FODatabaseConfig {
//@Value("${spring.r2dbc.fo.connection.url}")
private String url = "r2dbc:postgresql://username:password@database-dev-fo-css-rr-db.corp.com:1200/fo_pgdb";
@Bean
@Qualifier("foConnectionFactory")
public ConnectionFactory foConnectionFactory() {
return ConnectionFactories.get(url);
}
@Bean
public R2dbcEntityOperations foEntityTemplate(@Qualifier("foConnectionFactory") ConnectionFactory connectionFactory) {
DefaultReactiveDataAccessStrategy strategy = new DefaultReactiveDataAccessStrategy(PostgresDialect.INSTANCE);
DatabaseClient databaseClient = DatabaseClient.builder()
.connectionFactory(connectionFactory)
.bindMarkers(PostgresDialect.INSTANCE.getBindMarkersFactory())
.build();
return new R2dbcEntityTemplate(databaseClient, strategy);
}
}
@Configuration
@EnableR2dbcRepositories(entityOperationsRef = "ifEntityTemplate")
public class IFDatabaseConfig {
//@Value("${spring.r2dbc.if.connection.url}")
private String url = "r2dbc:postgresql://username:password@database-blue-if-CSS-db.corp.com:1200/if_pgdb";
@Bean
@Qualifier("ifConnectionFactory")
public ConnectionFactory ifConnectionFactory() {
return ConnectionFactories.get(url);
}
@Bean
public R2dbcEntityOperations ifEntityTemplate(@Qualifier("ifConnectionFactory") ConnectionFactory connectionFactory) {
DefaultReactiveDataAccessStrategy strategy = new DefaultReactiveDataAccessStrategy(PostgresDialect.INSTANCE);
DatabaseClient databaseClient = DatabaseClient.builder()
.connectionFactory(connectionFactory)
.bindMarkers(PostgresDialect.INSTANCE.getBindMarkersFactory())
.build();
return new R2dbcEntityTemplate(databaseClient, strategy);
}
}
@Service
@RequiredArgsConstructor
public class CrewMemberSchedulePeriodPaymentService {
private final FOCrewMemberBidLineRepository foCrewMemberBidlineRepository;
private final IFCrewMemberBidLineRepository ifCrewMemberBidLineRepository;
public Flux<FOCrewMemberBidLine> getFOBidLines(List<Long> id) {
return foCrewMemberBidlineRepository.findAllById(id);
}
public Flux<IFCrewMemberBidLine> getIFBidLines(List<Long> id) {
return ifCrewMemberBidLineRepository.findAllById(id);
}
}
@Repository
public interface FOCrewMemberBidLineRepository extends R2dbcRepository<FOCrewMemberBidLine, Long> {
@Override
Flux<FOCrewMemberBidLine> findAllById(Iterable<Long> longs);
}
@Repository
public interface IFCrewMemberBidLineRepository extends R2dbcRepository<IFCrewMemberBidLine, Long> {
@Override
Flux<IFCrewMemberBidLine> findAllById(Iterable<Long> longs);
}
@Table(value = "BID_LINES")
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
public class FOCrewMemberBidLine {
@Id
@Column(value = "bidlinseqnumber")
private Long bidlinseqnumber;
@Column(value = "bidlinschedperiod")
private String bidlinschedperiod;
}
@Table(value = "BID_LINES")
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
public class IFCrewMemberBidLine {
@Id
@Column(value = "bidlinseqnumber")
private Long bidlinseqnumber;
@Column(value = "bidlinschedperiod")
private String bidlinschedperiod;
}