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? :)