dimanche 19 avril 2015

Because of Hibernate Mapping need to have some of the fields as @Transient but JSP does not have access to them

In Java, I have access to value of Transient fields of the class. However, I do not access to the same fields on JSP. How can I make them available to JSP?


I am retrieving the values using Hibernate, I reckon a solution to this would be to Transformers.aliasToBean option but is there any other solution to it?


Is there anyway to get rid of transient annotation but have the same mapping in Hibernate? In that case, the problem will be solved.



@AssociationOverrides({
@AssociationOverride(name = "tta.names", joinColumns = @JoinColumn(name = "id"))})
public class Names implements java.io.Serializable {

private static final long serialVersionUID = -30956546435023625398L;

@EmbeddedId
private TableToAssociate tta = new TableToAssociate();


@Transient
public String getid() {
return tta.getMyIds().getId();
}

public void setid(String id) {
this.tta.getMyIds().setId(id);
}


In Java, I can access them using following code



System.out.println(mystudents.getNames().iterator().next().getId());


In JSP, I do not have access to them!



<c:forEach var="nm"items="${mystudents.names}">
${nm.id}
</c:forEach>


If I put another field of names that is not transient , JSP successfully show the value of that item.


Aucun commentaire:

Enregistrer un commentaire