Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.0.2.RELEASE
-
Fix Version/s: 1.1.0.M1
-
Component/s: GENERAL OBJECTS
-
Labels:None
Description
Given an entity like this:
@Entity
@RooJavaBean
@RooToString
@RooEntity
public class HistoricalItem {
@NotNull
@Size(min = 1)
private String title;
@Temporal(TemporalType.TIMESTAMP)
@DateTimeFormat(style = "MM", iso = ISO.DATE_TIME)
private Calendar lastUpdated;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "historicalItem")
private Set<HistoricalPrice> historicalPrices = new HashSet<HistoricalPrice>();
@PrePersist
protected void onCreate()
@PreUpdate
protected void onUpdate()
}
Roo generates a ToString like this:
public String HistoricalItem.toString() {
StringBuilder sb = new StringBuilder();
sb.append("Id: ").append(getId()).append(", ");
sb.append("Version: ").append(getVersion()).append(", ");
sb.append("Title: ").append(getTitle()).append(", ");
sb.append("DateCreated: ").append(getDateCreated().getTime()).append(", "); // Throws NPE !!!
sb.append("LastUpdated: ").append(getLastUpdated().getTime()).append(", "); // Throws NPE !!!
return sb.toString();
}
I need dateCreated and lastUpdated to be null when creating the entity so initializing them is not an option.
Roo needs to add the necessary null checks before attempting to call Calendar.getTime()
Attachments
Issue Links
- supersedes
-
ROO-797 @RooToString doesn
-
- Closed
-