Thanks, Hardy. For the second issue, here are the classes involved (simplified to just the members - I'm doing field-level annotation):
Physician
Code:
@Entity @Table(name = "MDS_PHYSICIAN")
@Indexed
public class Physician extends PersistentEntity
{
//~ Statics ------------------------------------------------------------------
static private final long serialVersionUID = 1934834917682898622L;
//~ Members ------------------------------------------------------------------
@Basic @Column(name = "PHYS_ADMIN_EMAIL_ADDR")
private String adminEmailAddress;
@OneToMany(mappedBy = "physician")
@IndexedEmbedded
private Set<PhysicianAffiliation> affiliations;
@OneToMany(mappedBy = "physician")
@IndexedEmbedded
private Set<PhysicianExpertise> areasOfExpertise;
@Column(name = "PHYS_BIRTH_DT")
@Temporal(TemporalType.TIMESTAMP)
private Date birthDate;
@Basic @Column(name = "PHYS_DIRECTORSHIP")
private String directorship;
@OneToMany(mappedBy = "physician")
private Set<PhysicianEducationProgram> educationPrograms;
@Basic @Column(name = "PHYS_EMAIL_ADDR")
private String emailAddress;
@Basic @Column(name = "PHYS_FIRST_NM", nullable = false)
@Fields({
@Field(index = Index.TOKENIZED, store = Store.NO),
@Field(name = "firstName_sort", index = Index.UN_TOKENIZED, store = Store.NO)
})
private String firstName;
@JoinColumn(name = "PHYS_GENDER_CD")
@ManyToOne(fetch = FetchType.LAZY)
private MdsCode genderCode;
@Column(name = "PHYS_ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
@Id
private Long id;
@OneToMany(mappedBy = "physician")
private Set<PhysicianInsurancePlan> insurancePlans;
@Basic @Column(name = "PHYS_LAST_NM", nullable = false)
@Fields({
@Field(index = Index.TOKENIZED, store = Store.NO),
@Field(name = "lastName_sort", index = Index.UN_TOKENIZED, store = Store.NO)
})
private String lastName;
@Column(name = "PHYS_MAINT_DT")
@Temporal(TemporalType.TIMESTAMP)
private Date maintDate;
@Basic @Column(name = "PHYS_NO")
private String mdNumber;
@Basic @Column(name = "PHYS_MI")
private String middleInitial;
@Basic @Column(name = "PHYS_NPI_NO")
private String npiNumber;
@OneToMany(mappedBy = "physician")
private Set<PhysicianOffice> offices;
@Column(name = "PHYS_ON_STAFF_DT")
@Temporal(TemporalType.TIMESTAMP)
private Date onStaffDate;
@JoinColumn(name = "PHYS_RANK_CD")
@ManyToOne(fetch = FetchType.LAZY)
private MdsCode rankCode;
@OneToMany(mappedBy = "physician")
@IndexedEmbedded
private Set<PhysicianSpecialty> specialties;
@JoinColumn(name = "PHYS_STATUS_CD")
@ManyToOne(fetch = FetchType.LAZY)
private MdsCode statusCode;
@Column(name = "PHYS_STATUS_FROM_DT")
@Temporal(TemporalType.TIMESTAMP)
private Date statusFromDate;
@OneToMany(mappedBy = "physician")
private Set<PhysicianTitle> titles;
@Basic @Column(name = "PHYS_YR_BEGIN_PRACTICE")
private int yearBeganPractice;
PhysicianTitle
Code:
@Entity @Table(name = "MDS_PHYSICIAN_TITLE")
public class PhysicianTitle extends PersistentEntity
{
//~ Statics ------------------------------------------------------------------
static private final long serialVersionUID = 1934834917682898622L;
//~ Members ------------------------------------------------------------------
@Basic @Column(name = "PHYS_TITLE_DESC", nullable = false)
private String description;
@Column(name = "PHYS_TITLE_ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
@Id
private Long id;
@JoinColumn(name = "PHYS_ID")
@ManyToOne(fetch = FetchType.LAZY)
private Physician physician;
}
PersistentEntity
Code:
@MappedSuperclass
public abstract class PersistentEntity implements Cloneable, Serializable
{
//~ Statics ------------------------------------------------------------------
static private final Log LOG = LogFactory.getLog(PersistentEntity.class);
static private final long serialVersionUID = -7935676908641580483L;
//~ Members ------------------------------------------------------------------
@Column(name = "ACTIVE_FLG", nullable = false, length = 1)
@Type(type = "yes_no")
@Field(index=Index.UN_TOKENIZED, store=Store.NO)
private Boolean active;
@Basic @Column(name = "CREATED_BY", length = 30, nullable = false)
private String createdBy;
@Column(name = "CREATE_DT", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date createdDate;
@Basic @Column(name = "MODIFIED_BY", length = 30, nullable = false)
private String modifiedBy;
@Column(name = "MODIFIED_DT", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date modifiedDate;
//~ Constructors -------------------------------------------------------------
public PersistentEntity()
{
this.active = Boolean.FALSE;
}
//~ Methods ------------------------------------------------------------------
public abstract Long getId();
public abstract void setId(Long id);
}
And the generated SQL:
Code:
Hibernate:
select
this_.PHYS_ID as PHYS1_6_0_,
this_.ACTIVE_FLG as ACTIVE2_6_0_,
this_.CREATED_BY as CREATED3_6_0_,
this_.CREATE_DT as CREATE4_6_0_,
this_.MODIFIED_BY as MODIFIED5_6_0_,
this_.MODIFIED_DT as MODIFIED6_6_0_,
this_.PHYS_ADMIN_EMAIL_ADDR as PHYS7_6_0_,
this_.PHYS_BIRTH_DT as PHYS8_6_0_,
this_.PHYS_DIRECTORSHIP as PHYS9_6_0_,
this_.PHYS_EMAIL_ADDR as PHYS10_6_0_,
this_.PHYS_FIRST_NM as PHYS11_6_0_,
this_.PHYS_GENDER_CD as PHYS20_6_0_,
this_.PHYS_LAST_NM as PHYS12_6_0_,
this_.PHYS_MAINT_DT as PHYS13_6_0_,
this_.PHYS_NO as PHYS14_6_0_,
this_.PHYS_MI as PHYS15_6_0_,
this_.PHYS_NPI_NO as PHYS16_6_0_,
this_.PHYS_ON_STAFF_DT as PHYS17_6_0_,
this_.PHYS_RANK_CD as PHYS21_6_0_,
this_.PHYS_STATUS_CD as PHYS22_6_0_,
this_.PHYS_STATUS_FROM_DT as PHYS18_6_0_,
this_.PHYS_YR_BEGIN_PRACTICE as PHYS19_6_0_
from
MDS_PHYSICIAN this_
where
(
this_.PHYS_ID in (
?, ?
)
)
Hibernate:
select
titles0_.PHYS_ID as PHYS8_6_1_,
titles0_.PHYS_TITLE_ID as PHYS1_1_,
titles0_.PHYS_TITLE_ID as PHYS1_4_0_,
titles0_.ACTIVE_FLG as ACTIVE2_4_0_,
titles0_.CREATED_BY as CREATED3_4_0_,
titles0_.CREATE_DT as CREATE4_4_0_,
titles0_.MODIFIED_BY as MODIFIED5_4_0_,
titles0_.MODIFIED_DT as MODIFIED6_4_0_,
titles0_.PHYS_TITLE_DESC as PHYS7_4_0_,
titles0_.PHYS_ID as PHYS8_4_0_
from
MDS_PHYSICIAN_TITLE titles0_
where
titles0_.PHYS_ID=?
Thanks for any help.
Michael