Open gaeshi opened 1 year ago
@gaeshi Is the only issue the false-positive warning? Or is some functionality affected, too?
@elefeint
It does look like the code is running fine.
I tried looking at the InterleavedTest, thinking that I'm not using the library properly, but unfortunately there were only the tests for @EmbeddedId
.
The example in the README.md
, suggests using IdClass
instead:
@Entity
@Interleaved(parentEntity = Singer.class, cascadeDelete = true)
@IdClass(AlbumId.class)
public class Album {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Type(type = "uuid-char")
private UUID albumId;
@Id
@ManyToOne
@JoinColumn(name = "singerId")
@Type(type = "uuid-char")
private Singer singer;
// Constructors, getters/setters
public static class AlbumId implements Serializable {
// The primary key columns of the parent entity
// must be declared first.
Singer singer;
@Type(type = "uuid-char")
UUID albumId;
// Getters and setters
}
}
@Entity
public class Singer {
@OneToMany(mappedBy = "singer")
List<Album> albums;
// continued...
}
But I couldn't find any tests for this.
Here is a minimal PoC to reproduce the issue: https://github.com/mixefy/spanner-hibernate-interleaved-poc
@olavloite @JoeWang1127 FYI.
How to reproduce:
The following WARN log appears:
However, the tables are created fine and the code seems to run fine.
Looks like
com.google.cloud.spanner.hibernate.schema.SchemaUtils.resolveIdFields()
isn't resolving the actualId
fields of the parent entity in case@IdClass
is used.