Skip to content

Instantly share code, notes, and snippets.

@dagvadorj
Last active August 29, 2015 14:01
Show Gist options
  • Save dagvadorj/df74cbd82382a4f9b1b0 to your computer and use it in GitHub Desktop.
Save dagvadorj/df74cbd82382a4f9b1b0 to your computer and use it in GitHub Desktop.
Item properties
@Entity
public class Item implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
@MapKeyJoinColumn
@ManyToMany(cascade = CascadeType.ALL)
private Map<ItemProperty, ItemPropertyValues> properties;
}
@Entity
public class ItemProperty implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
}
@Entity
public class ItemPropertyValues implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ElementCollection(fetch = FetchType.EAGER, targetClass = String.class)
private List<String> propertyValues;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment