I am using spring MVC with the rest of the web services (JACKSON). I have a p_project table that has 3 columns. id, region_id, name. region_id refers to the region table. My essence is as shown in the code.
@Entity @XmlRootElement(name="project") @Table(name = "P_PROJECT") @NamedQueries( { @NamedQuery(name = "Project.findAll", query = "select p from Project p order by lower(p.name)", hints = { @QueryHint(name = "org.hibernate.cacheable", value = "true") } ) }) public class Project extends AbstractSimpleNameEntity<Integer> implements Serializable { private Region region; private String name; public Project() { super(); } public Project(Integer id) { super(id); } public Project(String name) { super(name); } @Id @Column(name = "ID") @GeneratedValue(generator = "P_PROJECT_SEQ", strategy = GenerationType.SEQUENCE) @SequenceGenerator(name = "P_PROJECT_SEQ", sequenceName = "P_PROJECT_SEQ", allocationSize = 1) public Integer getId() { return id; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "REGION_ID") public Region getRegion() { return region; } public void setRegion(Region region) { this.region = region; } @Column(name = "NAME") public String getName() { return name; } }
When retrieving the entire project, I get the following error. Can anyone help?
org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.ArrayList[0]->com.sony.prince.entity.Project["region"]-> com.sony.prince.entity.Region_$$_javassist_2["hibernateLazyInitializer"])
source share