forked from telosys-tools-beta/java8-commons-T312
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXxxPersistence_java.vm
91 lines (76 loc) · 2.26 KB
/
XxxPersistence_java.vm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#parse("/include/init_var_entity.vm")
#parse("/include/java_header.vm")
package ${target.javaPackageFromFolder(${SRC})};
import java.util.List;
import ${recordPackage}.${recordClass};
/**
* Persistence Interface for ${recordClass}.
*/
public interface ${entity.name}Persistence {
/**
* Tries to find an entity using its Id / Primary Key
#foreach( $attribute in $entity.keyAttributes )
* @param $attribute.name
#end
* @return entity
*/
${recordClass} findById( $fn.argumentsListWithWrapperType($entity.keyAttributes) ) ;
/**
* Finds all entities.
* @return all entities
*/
List<${recordClass}> findAll();
/**
* Counts all the records present in the database
* @return
*/
public long countAll() ;
/**
* Saves the given entity in the database (create or update)
* @param entity
* @return entity
*/
${recordClass} save(${recordClass} entity);
/**
* Updates the given entity in the database
* @param entity
* @return true if the entity has been updated, false if not found and not updated
*/
## ${recordClass} update(${recordClass} entity);
boolean update(${recordClass} entity);
/**
* Creates the given entity in the database
* @param entity
* @return
*/
${recordClass} create(${recordClass} entity);
/**
* Deletes an entity using its Id / Primary Key
#foreach( $attribute in $entity.keyAttributes )
* @param $attribute.name
#end
* @return true if the entity has been deleted, false if not found and not deleted
*/
## void delete( $fn.argumentsListWithType($entity.keyAttributes) );
boolean deleteById( $fn.argumentsListWithWrapperType($entity.keyAttributes) );
/**
* Deletes an entity using the Id / Primary Key stored in the given object
* @param the entity to be deleted (supposed to have a valid Id/PK )
* @return true if the entity has been deleted, false if not found and not deleted
*/
boolean delete( ${recordClass} entity );
/**
* Returns true if an entity exists with the given Id / Primary Key
#foreach( $attribute in $entity.keyAttributes )
* @param $attribute.name
#end
* @return
*/
public boolean exists( $fn.argumentsListWithWrapperType($entity.keyAttributes) ) ;
/**
* Returns true if the given entity exists
* @param entity
* @return
*/
public boolean exists( ${recordClass} entity ) ;
}