@Documented @Target(value=TYPE) @Retention(value=RUNTIME) public @interface Interleaved
Entity class that should be interleaved in
a parent table. This annotation is Cloud Spanner specific and is only used when automatic schema
generation is used. If you create your schema manually, you may leave this annotation out.
To generate the following schema:
CREATE TABLE ParentTable (ParentId INT64, Name STRING(MAX)) PRIMARY KEY (ParentId);
CREATE TABLE ChildTable (ParentId INT64, ChildId INT64, ChildName STRING(MAX))
PRIMARY KEY (ParentId, ChildId),
INTERLEAVE IN PARENT ParentTable
The following Java definition should be used:
@Entity
@Table(name = "ParentTable")
public class Parent {
@Id
private Long parentId;
@Column
private String name;
...
}
@Entity
@Table(name = "ChildTable")
@Interleaved(parentEntity = Parent.class)
public class Child {
public static class ChildId implements Serializable {
private Long parentId;
private Long childId;
...
}
@EmbeddedId
private ChildId id;
@Column
private String ChildName
...
}
| Modifier and Type | Required Element and Description |
|---|---|
Class<?> |
parentEntity
The parent table that this table will be interleaved in.
|
| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
cascadeDelete
Indicates whether when a row from the parent table is deleted that the child rows in this table
will automatically be deleted as well.
|
public abstract Class<?> parentEntity
Copyright © 2022 Google LLC. All rights reserved.