5

I am using spring MVC with restful web services (JACKSON). I have table called p_project which has 3 columns. id, region_id, name. region_id referneces to region table. My entity 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;
}
}

While fetching all the project i am getting the following error. Can some one please 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"])
Heiko Rupp
  • 30,426
  • 13
  • 82
  • 119
user732362
  • 395
  • 4
  • 10
  • 19
  • I am running into a similar problem. Hope to see some insight on why this is happening – pbojinov Feb 22 '12 at 00:21
  • Here is a thread with a similar kind of problem. hope this helps to an extent. http://stackoverflow.com/questions/4362104/strange-jackson-exception-being-thrown-when-serializing-hibernate-object – firefox784 Feb 29 '12 at 18:16

0 Answers0