Seam-gen generates compile error
sdthomas Nov 6, 2007 4:58 PMI am attempting to reverse engineer a database with seam-gen/generate-entities. Everything is built correctly. But the isDefined() method in the generated TransectHome class incorrectly applies a Strings.isEmpty() method (the objects are not always Strings). Is this a bug?
Generated Pojo
@Entity
@Table(name = "transect", schema = "public")
public class Transect implements java.io.Serializable {
private TransectId id;
public Transect() {
}
public Transect(TransectId id) {
this.id = id;
}
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "pkTransect", column = @Column(name = "pk_transect", nullable = false)),
@AttributeOverride(name = "transectId", column = @Column(name = "transect_id")),
@AttributeOverride(name = "transectName", column = @Column(name = "transect_name")),
@AttributeOverride(name = "groupedData", column = @Column(name = "grouped_data")),
@AttributeOverride(name = "plots", column = @Column(name = "plots"))})
@NotNull
public TransectId getId() {
return this.id;
}
public void setId(TransectId id) {
this.id = id;
}
}Generated Id Class
@Embeddable
public class TransectId implements java.io.Serializable {
private int pkTransect;
private Integer transectId;
private String transectName;
private Integer groupedData;
private String plots;
public TransectId() {
}
public TransectId(int pkTransect) {
this.pkTransect = pkTransect;
}
public TransectId(int pkTransect, Integer transectId, String transectName,
Integer groupedData, String plots) {
this.pkTransect = pkTransect;
this.transectId = transectId;
this.transectName = transectName;
this.groupedData = groupedData;
this.plots = plots;
}
@Column(name = "pk_transect", nullable = false)
@NotNull
public int getPkTransect() {
return this.pkTransect;
}
public void setPkTransect(int pkTransect) {
this.pkTransect = pkTransect;
}
@Column(name = "transect_id")
public Integer getTransectId() {
return this.transectId;
}
public void setTransectId(Integer transectId) {
this.transectId = transectId;
}
@Column(name = "transect_name")
public String getTransectName() {
return this.transectName;
}
public void setTransectName(String transectName) {
this.transectName = transectName;
}
@Column(name = "grouped_data")
public Integer getGroupedData() {
return this.groupedData;
}
public void setGroupedData(Integer groupedData) {
this.groupedData = groupedData;
}
@Column(name = "plots")
public String getPlots() {
return this.plots;
}
public void setPlots(String plots) {
this.plots = plots;
}
public boolean equals(Object other) {
if ((this == other))
return true;
if ((other == null))
return false;
if (!(other instanceof TransectId))
return false;
TransectId castOther = (TransectId) other;
return (this.getPkTransect() == castOther.getPkTransect())
&& ((this.getTransectId() == castOther.getTransectId()) || (this
.getTransectId() != null
&& castOther.getTransectId() != null && this
.getTransectId().equals(castOther.getTransectId())))
&& ((this.getTransectName() == castOther.getTransectName()) || (this
.getTransectName() != null
&& castOther.getTransectName() != null && this
.getTransectName().equals(castOther.getTransectName())))
&& ((this.getGroupedData() == castOther.getGroupedData()) || (this
.getGroupedData() != null
&& castOther.getGroupedData() != null && this
.getGroupedData().equals(castOther.getGroupedData())))
&& ((this.getPlots() == castOther.getPlots()) || (this
.getPlots() != null
&& castOther.getPlots() != null && this.getPlots()
.equals(castOther.getPlots())));
}
public int hashCode() {
int result = 17;
result = 37 * result + this.getPkTransect();
result = 37
* result
+ (getTransectId() == null ? 0 : this.getTransectId()
.hashCode());
result = 37
* result
+ (getTransectName() == null ? 0 : this.getTransectName()
.hashCode());
result = 37
* result
+ (getGroupedData() == null ? 0 : this.getGroupedData()
.hashCode());
result = 37 * result
+ (getPlots() == null ? 0 : this.getPlots().hashCode());
return result;
}
}Generated Action Class
@Name("transectHome")
public class TransectHome extends EntityHome<Transect> {
public void setTransectId(TransectId id) {
setId(id);
}
public TransectId getTransectId() {
return (TransectId) getId();
}
public TransectHome() {
setTransectId(new TransectId());
}
@Override
public boolean isIdDefined() {
if (getTransectId().getPkTransect() == 0)
return false;
if (Strings.isEmpty(getTransectId().getTransectId()))
return false;
if (Strings.isEmpty(getTransectId().getTransectName()))
return false;
if (Strings.isEmpty(getTransectId().getGroupedData()))
return false;
if (Strings.isEmpty(getTransectId().getPlots()))
return false;
return true;
}
@Override
protected Transect createInstance() {
Transect transect = new Transect();
transect.setId(new TransectId());
return transect;
}
public void wire() {
}
public boolean isWired() {
return true;
}
public Transect getDefinedInstance() {
return isIdDefined() ? getInstance() : null;
}
}