You can use foreign key in embedded id as a separate read-only column:

@Entity 
public class Entity2 { 

    @EmbeddedId 
    private Entity2PK pk = new Entity2PK(); 

    @ManyToOne 
    @JoinColumn(name = "entity1_id")
    private Entity1 entity; 

    ... 
} 

@Embeddable 
public class Entity2PK implements Serializable { 

    @GeneratedValue 
    private Long id; 

    @Column(name = "entity1_id", insertable = false, updateable = false)
    private Long entity1Id;

}


How to create an entity with a composite primary key containing a generated value
What are the boundaries for when one says סברי or ברשות before making a blessing?
(As an example, my siddur has סברי מרנן ורבנן ורבותי printed before the blessing of hagafen for kiddush.)
