Skip to content

Commit 85b2d58

Browse files
vcharmcasterSanne
authored andcommitted
java doc added
1 parent 5076368 commit 85b2d58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2070
-0
lines changed

hibernate-orm/core/Caching/src/main/java/org/hibernate/brmeyer/demo/AbstractCachingDemo.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@
2929
import org.hibernate.cfg.Configuration;
3030

3131
/**
32+
* The Class AbstractCachingDemo.
33+
*
3234
* @author Brett Meyer
3335
*/
3436
public class AbstractCachingDemo {
3537

38+
/** The session factory. */
3639
protected final SessionFactory sessionFactory;
3740

41+
/**
42+
* Instantiates a new abstract caching demo.
43+
*/
3844
protected AbstractCachingDemo() {
3945
final Configuration configuration = new Configuration();
4046
configuration.addAnnotatedClass( Project.class );
@@ -44,10 +50,20 @@ protected AbstractCachingDemo() {
4450
new StandardServiceRegistryBuilder().build() );
4551
}
4652

53+
/**
54+
* Open session.
55+
*
56+
* @return the session
57+
*/
4758
protected Session openSession() {
4859
return sessionFactory.openSession();
4960
}
5061

62+
/**
63+
* Persist data.
64+
*
65+
* @return the long
66+
*/
5167
public long persistData() {
5268
final Project project = new Project();
5369
project.setName( "Foo Project" );

hibernate-orm/core/Caching/src/main/java/org/hibernate/brmeyer/demo/QueryCachingDemo.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,18 @@
2828

2929

3030
/**
31+
* The Class QueryCachingDemo.
32+
*
3133
* @author Brett Meyer
3234
*/
3335
public class QueryCachingDemo extends AbstractCachingDemo {
3436

37+
/**
38+
* Gets the project.
39+
*
40+
* @param id the id
41+
* @return the project
42+
*/
3543
public Project getProject(long id) {
3644
final Session s = openSession();
3745
s.getTransaction().begin();
@@ -43,6 +51,11 @@ public Project getProject(long id) {
4351
return project;
4452
}
4553

54+
/**
55+
* Gets the projects.
56+
*
57+
* @return the projects
58+
*/
4659
public List<Project> getProjects() {
4760
final Session s = openSession();
4861
s.getTransaction().begin();
@@ -53,6 +66,12 @@ public List<Project> getProjects() {
5366
return projects;
5467
}
5568

69+
/**
70+
* Update project.
71+
*
72+
* @param id the id
73+
* @param name the name
74+
*/
5675
public void updateProject(long id, String name) {
5776
final Session s = openSession();
5877
s.getTransaction().begin();
@@ -62,16 +81,27 @@ public void updateProject(long id, String name) {
6281
s.getTransaction().commit();
6382
}
6483

84+
/**
85+
* Evict.
86+
*/
6587
public void evict() {
6688
sessionFactory.getCache().evictDefaultQueryRegion();
6789
}
6890

91+
/**
92+
* Prints the stats.
93+
*/
6994
public void printStats() {
7095
System.out.println("query cache put count: " + sessionFactory.getStatistics().getQueryCachePutCount());
7196
System.out.println("query cache hit count: " + sessionFactory.getStatistics().getQueryCacheHitCount());
7297
System.out.println("query cache miss count: " + sessionFactory.getStatistics().getQueryCacheMissCount());
7398
}
7499

100+
/**
101+
* The main method.
102+
*
103+
* @param args the arguments
104+
*/
75105
public static void main(String[] args) {
76106
final QueryCachingDemo demo = new QueryCachingDemo();
77107
final long projectId = demo.persistData();

hibernate-orm/core/Caching/src/main/java/org/hibernate/brmeyer/demo/SecondLevelCachingDemo.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,18 @@
2626

2727

2828
/**
29+
* The Class SecondLevelCachingDemo.
30+
*
2931
* @author Brett Meyer
3032
*/
3133
public class SecondLevelCachingDemo extends AbstractCachingDemo {
3234

35+
/**
36+
* Gets the project.
37+
*
38+
* @param id the id
39+
* @return the project
40+
*/
3341
public Project getProject(long id) {
3442
final Session s = openSession();
3543
s.getTransaction().begin();
@@ -38,6 +46,12 @@ public Project getProject(long id) {
3846
return project;
3947
}
4048

49+
/**
50+
* Gets the user.
51+
*
52+
* @param id the id
53+
* @return the user
54+
*/
4155
public User getUser(long id) {
4256
final Session s = openSession();
4357
s.getTransaction().begin();
@@ -46,16 +60,29 @@ public User getUser(long id) {
4660
return user;
4761
}
4862

63+
/**
64+
* Evict project.
65+
*
66+
* @param projectId the project id
67+
*/
4968
public void evictProject(long projectId) {
5069
sessionFactory.getCache().evictEntity( Project.class, projectId );
5170
}
5271

72+
/**
73+
* Prints the stats.
74+
*/
5375
public void printStats() {
5476
System.out.println("2lc put count: " + sessionFactory.getStatistics().getSecondLevelCachePutCount());
5577
System.out.println("2lc hit count: " + sessionFactory.getStatistics().getSecondLevelCacheHitCount());
5678
System.out.println("2lc miss count: " + sessionFactory.getStatistics().getSecondLevelCacheMissCount());
5779
}
5880

81+
/**
82+
* The main method.
83+
*
84+
* @param args the arguments
85+
*/
5986
public static void main(String[] args) {
6087
final SecondLevelCachingDemo demo = new SecondLevelCachingDemo();
6188
final long projectId = demo.persistData();

hibernate-orm/core/Caching/src/main/java/org/hibernate/brmeyer/demo/entity/Project.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,41 +30,77 @@
3030
import org.hibernate.annotations.CacheConcurrencyStrategy;
3131

3232
/**
33+
* The Class Project.
34+
*
3335
* @author Brett Meyer
3436
*/
3537
@Entity
3638
@Cacheable
3739
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
3840
public class Project {
41+
42+
/** The id. */
3943
@Id
4044
@GeneratedValue
4145
private long id;
4246

47+
/** The name. */
4348
private String name;
4449

50+
/** The assignee. */
4551
@ManyToOne
4652
private User assignee;
4753

54+
/**
55+
* Gets the id.
56+
*
57+
* @return the id
58+
*/
4859
public long getId() {
4960
return id;
5061
}
5162

63+
/**
64+
* Sets the id.
65+
*
66+
* @param id the new id
67+
*/
5268
public void setId(long id) {
5369
this.id = id;
5470
}
5571

72+
/**
73+
* Gets the name.
74+
*
75+
* @return the name
76+
*/
5677
public String getName() {
5778
return name;
5879
}
5980

81+
/**
82+
* Sets the name.
83+
*
84+
* @param name the new name
85+
*/
6086
public void setName(String name) {
6187
this.name = name;
6288
}
6389

90+
/**
91+
* Gets the assignee.
92+
*
93+
* @return the assignee
94+
*/
6495
public User getAssignee() {
6596
return assignee;
6697
}
6798

99+
/**
100+
* Sets the assignee.
101+
*
102+
* @param assignee the new assignee
103+
*/
68104
public void setAssignee(User assignee) {
69105
this.assignee = assignee;
70106
}

hibernate-orm/core/Caching/src/main/java/org/hibernate/brmeyer/demo/entity/Skill.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,55 @@
99
import org.hibernate.annotations.CacheConcurrencyStrategy;
1010
import org.hibernate.annotations.Immutable;
1111

12+
/**
13+
* The Class Skill.
14+
*/
1215
@Entity
1316
@Immutable
1417
@Cacheable
1518
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
1619
public class Skill {
20+
21+
/** The id. */
1722
@Id
1823
@GeneratedValue
1924
private int id;
2025

26+
/** The name. */
2127
private String name;
2228

29+
/**
30+
* Gets the id.
31+
*
32+
* @return the id
33+
*/
2334
public int getId() {
2435
return id;
2536
}
2637

38+
/**
39+
* Sets the id.
40+
*
41+
* @param id the new id
42+
*/
2743
public void setId(int id) {
2844
this.id = id;
2945
}
3046

47+
/**
48+
* Gets the name.
49+
*
50+
* @return the name
51+
*/
3152
public String getName() {
3253
return name;
3354
}
3455

56+
/**
57+
* Sets the name.
58+
*
59+
* @param name the new name
60+
*/
3561
public void setName(String name) {
3662
this.name = name;
3763
}

0 commit comments

Comments
 (0)