Seam 2アプリをCDIに移行し、セキュリティのためにPicketLinkを使用しようとしています。すべての読み取りと調査の結果、すべての例でPicketLinkモデルとバックエンドエンティティの間に1対1のマッピングが行われているようです。例:Account to AccountEntity、Partition toPartitionEntity。IDモデルを表すエンティティがすでに配置されているため、それらをPicketLinkにマップしようとしています。これが私が持っているものです:
@MappedSuperClass
public class ModelEntityBase implement Serializable {
@Id @Generated
Long id;
Date creationDate;
}
@Entity
public Account extends ModelEntityBase {
String username;
String passwordHash;
@OneToOne(mappedBy = "account")
Person person;
}
@Entity
public Person extends ModelEntityBase {
String name;
String email;
@OneToOne
@JoinColumn(name = "account_id")
Account account;
}
PicketLinkの単一のIDモデルを表す2つのエンティティ(およびスーパークラス)。たとえば、ステレオタイプのユーザー。
これに基づいて、IdentityType idがLongではなくStringである理由に基づいて、次の場所に新しいエンティティを追加しようとしました。
@Entity
@IdentityManaged(BaseIdentityType.class);
public class IdentityTypeEntity implement Serializble {
@Id @Identifier
private String id;
@OneToOne(optional = false, mappedBy = "identityType")
@OwnerReference
private Account account;
@IdentityClass
private String typeName;
@ManyToOne @OwnerReference
private PartitionEntity partition;
}
アノテーションクラスとモデルクラスでいくつかの異なる方法を試しました。しかし、IdentityManager.add(myUserModel)を使用すると、すべてのエンティティにデータを入力することができません。これも可能ですか?
Pedro(PicketLink Dev)から助けを得ました。他の人を助けるためにここに答えを投稿してください。これは私が使用することになったモデルクラスです。
@IdentityStereotype(USER)
public class User extends AbstractAttributedType implements Account {
@AttributeProperty
private Account accountEntity;
@AttributeProperty
@StereotypeProperty(IDENTITY_USER_NAME)
@Unique
private String username;
@AttributeProperty
private boolean enabled;
@AttributeProperty
private Date createdDate;
@AttributeProperty
private Date expiryDate;
@AttributeProperty
private Partition partition;
// getter and setter omitted
}
そして、このモデルにマップする新しいエンティティを作成しました。
public class IdentityTypeEntity implements Serializable {
@Id
@Identifier
private String id;
@OneToOne(optional = false, mappedBy = "identityType",
cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@AttributeValue
// @NotNull
private HAccount accountEntity;
@IdentityClass
private String typeName;
@ManyToOne
@OwnerReference
private PartitionEntity partition;
@AttributeValue
private String username;
@AttributeValue
// @Transient
private boolean enabled;
@AttributeValue
private Date createdDate;
@AttributeValue
private Date expiryDate;
}
PLは、@ AttributePropertyを使用してプロパティを@AttributeValueを使用してエンティティプロパティにマップできます。ただし、マップできるのは1つのエンティティのみです。したがって、UserとそのプロパティをAccountとPersonにマッピングする方法はありません。ただし、モデルにエンティティ(私の場合はaccountEntity)を含めることができます。PLがこれらを必要とするため、新しいIdentityTypeEntityと既存のAccountエンティティ(username、eanbled、createdDate)のいくつかのフィールドも複製する必要があります。@PrePersistなどを使用して同期します。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加