-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: List I mapped returns wrong class
PostPosted: Thu Dec 02, 2010 6:47 am 
Newbie

Joined: Thu Dec 02, 2010 6:23 am
Posts: 1
Hi

We are making simple mmorpg for fun. Right now inventory mappings are bugged somehow, because List<ItemSlot> items returns Inventory object and not ItemSlot object (how is this even possible o.o).

I have Inventory.java that contains all inventory items and way to get them:
Code:
@Entity
@Table(name = "aegis_inventory")
public class Inventory
@Column(name = "item_owner")   
@Id
   private int id;   

@OneToMany(targetEntity=ItemSlot.class, fetch=FetchType.EAGER, mappedBy = "item_owner") //im trying to collect all items user has by using aegis_inventory.item_owner as id
   List<ItemSlot> items = new LinkedList<ItemSlot>();

//this one returns Inventory instead of ItemSlot - and throws ClassCastException   
public ItemSlot getItem(int slot) {
      return items.get(slot);
   }


And then there is ItemSlot.java which contains Item + some other info:
Code:
@Entity
@Table(name = "aegis_inventory")
public class ItemSlot
   @Embedded
   Item item;
   
   @Column(name = "slot")
   int slotNum;
   
   @Id
   private int item_owner;


finally there's Item.java which contains details on that item
Code:
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name = "item_templates")
@Embeddable
public class Item implements Serializable
@XmlAttribute(name = "id", required = true)
   @XmlID
   @Transient
   private String id;
   
   @XmlElement(name = "name")
   @Transient
   private String name;
   
   @XmlElement(name = "stack_size")
   @Transient
   private int maxStackSize;
   
   @XmlTransient
   @Column(name = "item_id")
   private int itemId;
   
   @XmlTransient
   @Enumerated(EnumType.ORDINAL)
   @Column(name = "slot_type")
   private ItemSlotType type;


Can someone help with this? :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.