I had been using hibernate tools 5.0.1 Beta 2 and there were no issues. I upgraded PCs, Eclipse and went to the new tools from the Marketplace. Now many entity POJOs do not have the primary key field as part of the constructor. The fields I have seen are all ones with generators (GUID and identity longs.) Tables without auto-generated key fields seem fine. Here is a sample:
{code:java}
/** * TblZipCode generated by hbm2java */ @Entity @Table(name = "tblZipCode", schema = "dbo", catalog = " asd_db1 xxx ") @SuppressWarnings("serial") public class TblZipCode implements java.io.Serializable {
private String zipid; private String zip; private String city; private String state; private String county; private String areaCode; private char cityType; private String cityAliasAbbreviation; private String cityAliasName; private BigDecimal latitude; private BigDecimal longitude; private short timeZone; private int elevation; private String countyFips; private String stateFips; private String dst; private Character classificationCode; private String multiCounty; private String cityAliasCode; private Character primaryRecord; private String cityMixedCase; private String cityAliasMixedCase;
public TblZipCode() { }
public TblZipCode(String zip, String city, String state, String county, String areaCode, char cityType, String cityAliasName, BigDecimal latitude, BigDecimal longitude, short timeZone, int elevation, String countyFips, String stateFips, String dst) { this.zip = zip; this.city = city; this.state = state; this.county = county; this.areaCode = areaCode; this.cityType = cityType; this.cityAliasName = cityAliasName; this.latitude = latitude; this.longitude = longitude; this.timeZone = timeZone; this.elevation = elevation; this.countyFips = countyFips; this.stateFips = stateFips; this.dst = dst; }
public TblZipCode(String zip, String city, String state, String county, String areaCode, char cityType, String cityAliasAbbreviation, String cityAliasName, BigDecimal latitude, BigDecimal longitude, short timeZone, int elevation, String countyFips, String stateFips, String dst, Character classificationCode, String multiCounty, String cityAliasCode, Character primaryRecord, String cityMixedCase, String cityAliasMixedCase) { this.zip = zip; this.city = city; this.state = state; this.county = county; this.areaCode = areaCode; this.cityType = cityType; this.cityAliasAbbreviation = cityAliasAbbreviation; this.cityAliasName = cityAliasName; this.latitude = latitude; this.longitude = longitude; this.timeZone = timeZone; this.elevation = elevation; this.countyFips = countyFips; this.stateFips = stateFips; this.dst = dst; this.classificationCode = classificationCode; this.multiCounty = multiCounty; this.cityAliasCode = cityAliasCode; this.primaryRecord = primaryRecord; this.cityMixedCase = cityMixedCase; this.cityAliasMixedCase = cityAliasMixedCase; }
@GenericGenerator(name = "generator", strategy = "guid") @Id @GeneratedValue(generator = "generator")
@Column(name = "ZIPID", unique = true, nullable = false, length = 36) public String getZipid() { return this.zipid; }
public void setZipid(String zipid) { this.zipid = zipid; }
{code} |
|