Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: hibernate annotations
Description: it is based on the topic hibernate annotations

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


Hibernate Annotations by RaghuSir

HIBERNATE ANNOTATIONS pom
...
hibernate
hibernate-core
4
...
4
...
hibernate
hibernate-validator
4
...
2
...
1
...
BASIC ANNOTATIONS:
@Entity
@Table(name="empt_tab")
@Id
@Column(name="eid")

2
...
AUTO)
@GeneratedValue(strategy=GenerationType
...
SEQUENCE)
@GeneratedValue(strategy=GenerationType
...
SEQUENCE,generator="sample")
@SequenceGenerator(name="sample",sequenceName="emp_seq")
@GeneratedValue(generator="sample")
@GenericGenerator(name="sample",strategy="com
...
model
...
DATE AND TIME:(java
...
DATE)
@Temporal(TemporalType
...
TIME)
private Date dateTwo;
@Temporal(TemporalType
...
BLOB and CLOB:
@Lob
private byte[] image;
@Lob
private char[] doc;

5
...
LIST, SET AND MAP WITH PRIMITIVES:
@ElementCollection
@CollectionTable(name="emp_dtls", //table
joinColumns=@JoinColumn(name="eidFk")) //key col
@Column(name="lst_data") //element col
private Set details=new HashSet(0);
@ElementCollection
@CollectionTable(name="emp_data", //table
joinColumns=@JoinColumn(name="eidFk")) //key col
@OrderColumn(name="pos") //index col
@Column(name="prjs") //element col
private List data=new ArrayList(0);
@ElementCollection
@CollectionTable(name="emp_models", //table
joinColumns=@JoinColumn(name="eidFk")) //key col
@MapKeyColumn(name="pos") //index col
@Column(name="model_data") //element col
private Map models=new HashMap();

2

7
...
INHERITANCE MAPPING:
i
...
SINGLE_TABLE)
@DiscriminatorColumn(name="ob_type",discriminatorType=DiscriminatorType
...
TABLE PER SUB CLASS
@Entity
@Table(name="emp")
@Inheritance(strategy=InheritanceType
...
TABLE PER CONCRETE CLASS
@Entity
@Table(name="emp")
@Inheritance(strategy=InheritanceType
...
ASSOCIATION MAPPING:
i
...
EAGER,cascade=CascadeType
...
Many-To-Many
@Entity
@Table(name="addrs_tab")
public class Address {
@Id
@Column(name="aid")
@GeneratedValue
private int addrId;
@Column(name="loc")
private String loc;
@ManyToMany(mappedBy="addr")
private List emp=new ArrayList(0);
}
@Entity
@Table(name="empt_tab")
class Employee{
@Id
@Column(name="eid");
private int empId;
@ManyToMany(cascade=CascadeType
...
EAGER)
@JoinTable(name="emp_addr",
joinColumns=@JoinColumn(name="eidFk"),
inverseJoinColumns=@JoinColumn(name="aidFk"))
private List
addr=new ArrayList
(0);
}
6

iii
...
ALL,fetch=FetchType
...
BAG AND IDBAG
Bag:
@ElementCollection
@CollectionTable(name="emp_data", //table
joinColumns=@JoinColumn(name="eidFk")) //key col
@Column(name="prjs") //element col
private List data=new ArrayList(0);

7

IdBag
@GenericGenerator(name="sample",strategy="increment")
@Entity
@Table(name="emp_tab")
class Employee{
@ElementCollection
@CollectionTable(name="emp_data", //table
joinColumns=@JoinColumn(name="eidFk")) //key col
@CollectionId(columns=@Column(name="unqPos"),
generator = "sample",
type = @Type(type="long"))
@Column(name="prjs") //element col
private List data=new ArrayList(0);
}

11
...
app
...
Employee where empId=?")
)
@Entity
@Table(name="empt_tab")
class Employee{}

12
...
class
)
})
@Entity
@Table(name="emp_tab")
class Employee {}
Test class:
Query q=ses
...
setParameter(0, 3);
List list=q
...
SECONDARY TABLE:
@Entity
@Table(name="emp_tab")
@SecondaryTables(
@SecondaryTable(name = "emp_child",
pkJoinColumns=@PrimaryKeyJoinColumn(
name="eidFk",referencedColumnName="eid")
)
)
class Employee {
@Id
@Column(name="eid")
int empId;
@Column(name="ename",table="emp_child")
String empName;
@Column(name="esal")
double empSal
}

14
Title: hibernate annotations
Description: it is based on the topic hibernate annotations