Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e0a7dcf7
authored
Apr 01, 2015
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add batchFetch for fetching place references. Speeds up init considerably
1 parent
9914e624
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
code/moya-database/src/main/java/fi/codecrew/moya/model/Place.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Place.java
View file @
e0a7dcf
...
@@ -32,6 +32,9 @@ import javax.persistence.Temporal;
...
@@ -32,6 +32,9 @@ import javax.persistence.Temporal;
import
javax.persistence.TemporalType
;
import
javax.persistence.TemporalType
;
import
javax.persistence.Transient
;
import
javax.persistence.Transient
;
import
org.eclipse.persistence.annotations.BatchFetch
;
import
org.eclipse.persistence.annotations.BatchFetchType
;
import
fi.codecrew.moya.utilities.NumericStringComparator
;
import
fi.codecrew.moya.utilities.NumericStringComparator
;
/**
/**
...
@@ -69,6 +72,7 @@ public class Place extends GenericEntity implements Comparable<Place> {
...
@@ -69,6 +72,7 @@ public class Place extends GenericEntity implements Comparable<Place> {
private
String
code
=
""
;
private
String
code
=
""
;
@OneToOne
(
mappedBy
=
"placeReservation"
)
@OneToOne
(
mappedBy
=
"placeReservation"
)
@BatchFetch
(
BatchFetchType
.
EXISTS
)
private
GroupMembership
placeReserver
;
private
GroupMembership
placeReserver
;
@Column
(
name
=
"buyable"
,
nullable
=
false
)
@Column
(
name
=
"buyable"
,
nullable
=
false
)
...
@@ -104,6 +108,11 @@ public class Place extends GenericEntity implements Comparable<Place> {
...
@@ -104,6 +108,11 @@ public class Place extends GenericEntity implements Comparable<Place> {
@ManyToOne
@ManyToOne
private
EventUser
currentUser
;
private
EventUser
currentUser
;
@OneToOne
(
mappedBy
=
"place"
)
@JoinColumn
(
nullable
=
true
)
@BatchFetch
(
BatchFetchType
.
EXISTS
)
private
PlaceSlot
reserverSlot
;
public
static
enum
PlaceState
{
public
static
enum
PlaceState
{
FREE
,
DISABLED
,
LOCKED
,
TEMP_RESERVED_FORME
,
FREE
,
DISABLED
,
LOCKED
,
TEMP_RESERVED_FORME
,
MY_PLACE
,
RESERVED
MY_PLACE
,
RESERVED
...
@@ -138,10 +147,6 @@ public class Place extends GenericEntity implements Comparable<Place> {
...
@@ -138,10 +147,6 @@ public class Place extends GenericEntity implements Comparable<Place> {
return
ret
;
return
ret
;
}
}
@OneToOne
(
mappedBy
=
"place"
)
@JoinColumn
(
nullable
=
true
)
private
PlaceSlot
reserverSlot
;
public
Place
()
{
public
Place
()
{
super
();
super
();
}
}
...
@@ -311,6 +316,7 @@ public class Place extends GenericEntity implements Comparable<Place> {
...
@@ -311,6 +316,7 @@ public class Place extends GenericEntity implements Comparable<Place> {
/**
/**
* NOTE: you can newer be sure that this is up to date
* NOTE: you can newer be sure that this is up to date
*
* @return
* @return
*/
*/
public
PlaceSlot
getReserverSlot
()
{
public
PlaceSlot
getReserverSlot
()
{
...
@@ -361,13 +367,13 @@ public class Place extends GenericEntity implements Comparable<Place> {
...
@@ -361,13 +367,13 @@ public class Place extends GenericEntity implements Comparable<Place> {
if
(
this
.
getName
()
==
null
||
o
.
getName
()
==
null
)
{
if
(
this
.
getName
()
==
null
||
o
.
getName
()
==
null
)
{
if
(
this
.
getName
()
==
null
)
{
if
(
this
.
getName
()
==
null
)
{
return
1
;
return
1
;
}
}
if
(
o
.
getName
()
==
null
)
{
if
(
o
.
getName
()
==
null
)
{
return
-
1
;
return
-
1
;
}
}
// both names are null. Compare IDs
// both names are null. Compare IDs
return
this
.
getNonNullId
().
compareTo
(
o
.
getNonNullId
());
return
this
.
getNonNullId
().
compareTo
(
o
.
getNonNullId
());
}
}
if
(
this
.
getName
().
equals
(
o
.
getName
()))
{
if
(
this
.
getName
().
equals
(
o
.
getName
()))
{
return
0
;
return
0
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment