-
Notifications
You must be signed in to change notification settings - Fork 565
Description
This issue is similar to #1729 .
Our app works as expected most of the time but occasionally we get a 404 error for some of our API endpoints.
When we check the /profile endpoint for that repository, it returns 500 with "Could not resolve repository metadata"
It works after a restart but then fails again after a while.
We use Spring-boot-starter-data-rest : 2.2.6.RELEASE
Example UseCase :
3 Entities :
- Customer
- AppTwitter
- CustomerTwitter
A Customer
can have multiple twitter Accounts (CustomerTwitter
). One Twitter App( AppTwitter
) can be used to handle multiple Customers
All of these entities have been exposed as repositories
Entites:
Customer.java
@Entity
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column( unique = true)
@NotBlank
private String name;
@ManyToOne
@JoinColumn(foreignKey=@ForeignKey(name = "FK_CustomerToAppTwitter"),name="appTwitter_id",referencedColumnName = "twitterAppId")
private AppTwitter appTwitter;
@OneToMany(cascade = CascadeType.ALL,mappedBy = "customer")
private List<CustomerTwitter> customerTwitter;
// Getters and Setters here
}
AppTwitter.java
@Entity
public class AppTwitter implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Integer twitterAppId;
// Other fields specific to App
@OneToMany(mappedBy = "appTwitter")
private List<Customer> customer;
//Getter and Setter
}
CustomerTwitter.java
@Entity
public class CustomerTwitter implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String twitterId
// Other fields related to twitter account
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(foreignKey=@ForeignKey(name = "FK_CustomerTwitterToCustomer"), name="cust_id",referencedColumnName = "id")
private Customer customer;
// Getters and Setters
}
Repositories
CustomerRepository.java
@RepositoryRestResource
public interface CustomerRepository extends JpaRepository<Customer, Integer>{
}
AppTwitterRepository.java
@RepositoryRestResource
public interface AppTwitterRepository extends JpaRepository<AppTwitter, Integer>{
}
CustomerTwitterRepository.java
@RepositoryRestResource
public interface CustomerTwitterRepository extends JpaRepository<CustomerTwitter, String>{
}
Sometimes making a GET call to any one of these endpoints returns 404 error and the /profile endpoint gives 500 error with Could not resolve repository metadata
Weird thing is this happens once every 6-7 hours and almost never happens in my local environment to even figure out and debug the issue.