3
3
import java .io .IOException ;
4
4
import java .io .InputStream ;
5
5
import java .io .Serializable ;
6
- import java .util .ArrayList ;
7
- import java .util .List ;
8
6
import java .util .Properties ;
9
7
import java .util .logging .Level ;
10
8
import java .util .logging .Logger ;
@@ -31,24 +29,15 @@ public BatchRepositoryImpl(JpaEntityInformation entityInformation,
31
29
32
30
@ Override
33
31
@ Transactional
34
- public <S extends T > S persist (S entity ) {
35
- entityManager .persist (entity );
36
-
37
- return entity ;
38
- }
39
-
40
- @ Override
41
- @ Transactional
42
- public <S extends T > Iterable <S > saveInBatch (Iterable <S > entities ) {
32
+ public <S extends T > void saveInBatch (Iterable <S > entities ) {
43
33
44
34
if (entities == null ) {
45
35
throw new IllegalArgumentException ("The given Iterable of entities cannot be null!" );
46
36
}
47
37
48
38
int i = 0 ;
49
- List <S > result = new ArrayList <>();
50
39
for (S entity : entities ) {
51
- result . add ( persist (entity ) );
40
+ entityManager . persist (entity );
52
41
53
42
i ++;
54
43
@@ -70,16 +59,14 @@ public <S extends T> Iterable<S> saveInBatch(Iterable<S> entities) {
70
59
entityManager .flush ();
71
60
entityManager .clear ();
72
61
}
73
-
74
- return result ;
75
62
}
76
63
77
64
private static int batchSize () {
78
65
79
66
int batchsize = Integer .valueOf (Dialect .DEFAULT_BATCH_SIZE ); // default batch size
80
67
81
68
Properties configuration = new Properties ();
82
- try ( InputStream inputStream = BatchRepositoryImpl .class .getClassLoader ()
69
+ try (InputStream inputStream = BatchRepositoryImpl .class .getClassLoader ()
83
70
.getResourceAsStream ("application.properties" )) {
84
71
configuration .load (inputStream );
85
72
} catch (IOException ex ) {
0 commit comments