I have a class ContactAddress.java which has this relationship
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name = "CNTRY_ID")
private Country country;
Country.java has these things
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "CNTRY_ID")
private Integer id;
@Column(name = "NM")
private String name;
@Column(name = "ISO_CD")
private String isoCode;
@Column(name = "SRT_ORDR")
private Integer sortOrder;
@OneToMany(mappedBy="country")
private List<State> states = new ArrayList<State>();
In ContactAddressAction.java I call the save method
public String save() throws Exception {
// Add the relationship
contactAddress.setAccount(getAccount());
// Is this an update?
if (index != null) {
getAccount().getContactAddresses().set(index, contactAddress);
} else {
List<ContactAddress> contactAddressList = getAccount().getContactAddresses();
contactAddressList.add(contactAddress);
//getAccount().getContactAddresses().add(contactAddress);
getAccount().setContactAddresses(contactAddressList);
}
return SUCCESS;
}
While calling this method the above exception comes.The list of contact adrreses are saved in the database but are not showing up immidiately after save.
JSP code
c:forEach items="${addresses}" var="address" varStatus="stat">
<s:url id="updateAddressUrl" action="update" namespace="/account/address">
<s:param name="index" value="${stat.index}" />
</s:url>
<s:url id="deleteAddressUrl" action="delete" namespace="/account/address">
<s:param name="index" value="${stat.index}" />
</s:url>
<tr class="address deletable">
<td>${address.type}</td>
<td>${address.primary ? 'Yes' : 'No'}</td>
<td>${address.active ? 'Yes' : 'No'}</td>
<td>${address.companyName}</td>
<td>
<v:address value="${address}"/>
<hr>
<table class="info">
<tr>
<th>Best Contact Time:</th>
<td>${address.bestContactTime}</td>
</tr>
<tr>
<th>Office Hours:</th>
<td>
Monday: <span class="value">${address.officeHourMonday}</span>
Tuesday:<span class="value">${address.officeHourTuesday}</span>
Wednesday:<span class="value">${address.officeHourWednesday}</span>
Thursday:<span class="value">${address.officeHourThursday}</span>
Friday:<span class="value">${address.officeHourFriday}</span>
</td>
</tr>
<tr>
<th>Lunch Time:</th>
<td>${address.officeLunchTime}</td>
</tr>
</table>
</td>
<td class="actions">
<a href="${updateAddressUrl}" class="popup-link button-link"><strong>Edit</strong></a>
<c:if test="${user.primaryAddressManageable}">
<a href="${deleteAddressUrl}" class="deletelink button-link"><strong>Delete</strong></a>
</c:if>
</td>
</tr>
</c:forEach>
Also, If I debug the code and look up the List variable through VARIABLES ,it's working fine and shows the list after saving.
Where am I not correct?