• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Web Service Response  RSS feed

Posts: 10
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am new to developing Web Services and have run into a problem with my web service. I have a web service exposed using Aegis mapping. The service implementation calls business logic which uses Hibernate to retrieve a record from DB. All is working fine from Hibernate implementation but when the web service is returning the response, the getter() on the object is being called recursively. Kindly help if I am doing something wrong.

Here is the code snippet

public Interface ItemService(){
public Item getItemList();

public class ItemServiceImpl() implements ItemService{
public Item getItemList(){
return ItemServiceManager.getItems();

public class ItemServiceManager(){
public static Item getItems(){
SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();

public class Item {

@Column(name = "Id")
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "ItemName")
private String itemName;
@Column(name = "ItemCategory")
private String itemCategory;

private Set<OrderItem> orderItems;

public Long getId() {
return id;

public void setId(Long id) {
this.id = id;

public String getItemName() {
return itemName;

public void setItemName(String itemName) {
this.itemName = itemName;

public String getItemCategory() {
return itemCategory;

public void setItemCategory(String itemCategory) {
this.itemCategory = itemCategory;

public Set<OrderItem> getOrderItems() {
return orderItems;

public void setOrderItems(Set<OrderItem> orderItems) {
this.orderItems = orderItems;


public class OrderItem {

@Column(name = "OrderItemId")
@GeneratedValue(strategy = GenerationType.AUTO)
private Long orderItemId;
@JoinColumn(name = "OrderId")
private Order order;

@JoinColumn(name = "ItemId")
private Item item;

public Long getOrderItemId() {
return orderItemId;

public void setOrderItemId(Long orderItemId) {
this.orderItemId = orderItemId;

public Order getOrder() {
return order;

public void setOrder(Order order) {
this.order = order;

public Item getItem() {
return item;

public void setItem(Item item) {
this.item = item;

On debugging, I observed that getOrderItems() in Item class and getItem() in OrderItem class are called recursively

Kindly help

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!