1 | if ( collection.needsInserting( entry, i, elementType ) ) {↵ | | 1 | int offset = 1;↵
|
|
2 | if ( useBatch ) {↵ | | 2 | if ( useBatch ) {↵
|
3 | if ( st == null ) {↵ | | 3 | if ( st == null ) {↵
|
4 | if ( callable ) {↵ | | 4 | if ( callable ) {↵
|
5 | st = session.getBatcher().prepareBatchCallableStatement( sql );↵ | | 5 | st = session.getBatcher().prepareBatchCallableStatement( sql );↵
|
6 | }↵ | | 6 | }↵
|
7 | else {↵ | | 7 | else {↵
|
8 | st = session.getBatcher().prepareBatchStatement( sql );↵ | | 8 | st = session.getBatcher().prepareBatchStatement( sql );↵
|
9 | }↵ | | 9 | }↵
|
10 | }↵ | | 10 | }↵
|
11 | }↵ | | 11 | }↵
|
12 | else {↵ | | 12 | else {↵
|
13 | if ( callable ) {↵ | | 13 | if ( callable ) {↵
|
14 | st = session.getBatcher().prepareCallableStatement( sql );↵ | | 14 | st = session.getBatcher().prepareCallableStatement( sql );↵
|
15 | }↵ | | 15 | }↵
|
16 | else {↵ | | 16 | else {↵
|
17 | st = session.getBatcher().prepareStatement( sql );↵ | | 17 | st = session.getBatcher().prepareStatement( sql );↵
|
18 | }↵ | | 18 | }↵
|
19 | }↵ | | 19 | }↵
|
|
20 | try {↵ | | 20 | try {↵
|
21 | offset += expectation.prepare( st );↵ | | 21 | offset+= expectation.prepare( st );↵
|
22 | //TODO: copy/paste from recreate()↵ | | 22 | ↵
|
23 | offset = writeKey( st, id, offset, session );↵ | | 23 | int loc = writeElement( st, collection.getElement( entry ), offset, session );↵
|
24 | if ( hasIdentifier ) {↵ | | 24 | if ( hasIdentifier ) {↵
|
25 | offset = writeIdentifier( st, collection.getIdentifier(entry, i), offset, session );↵ | | 25 | writeIdentifier( st, collection.getIdentifier( entry, i ), loc, session );↵
|
26 | }↵ | | 26 | }↵
|
| | | 27 | else {↵
|
| | | 28 | loc = writeKey( st, id, loc, session );↵
|
27 | if ( hasIndex /*&& !indexIsFormula*/ ) {↵ | | 29 | if ( hasIndex && !indexContainsFormula ) {↵
|
28 | offset = writeIndex( st, collection.getIndex(entry, i, this), offset, session );↵ | | 30 | writeIndexToWhere( st, collection.getIndex( entry, i, this ), loc, session );↵
|
29 | }↵ | | 31 | }↵
|
30 | ↵ | | 32 | else {↵
|
31 | writeElement(st, collection.getElement(entry), offset, session );↵ | | 33 | writeElementToWhere( st, collection.getSnapshotElement( entry, i ), loc, session );↵
|
|
32 | ↵ | | 34 | }↵
|
| | | 35 | }↵
|
|
33 | if ( useBatch ) {↵ | | 36 | if ( useBatch ) {↵
|
34 | session.getBatcher().addToBatch( expectation );↵ | | 37 | session.getBatcher().addToBatch( expectation );↵
|
35 | }↵ | | 38 | }↵
|
36 | else {↵ | | 39 | else {↵
|
37 | expectation.verifyOutcome( st.executeUpdate(), st, -1 );↵ | | 40 | expectation.verifyOutcome( st.executeUpdate(), st, -1 );↵
|
38 | }↵ | | 41 | }↵
|
39 | collection.afterRowInsert( this, entry, i );↵ | | 42 | ↵
|
40 | count++;↵ | | |
|
41 | }↵ | | 43 | }↵
|
42 | catch ( SQLException sqle ) {↵ | | 44 | catch ( SQLException sqle ) {↵
|
43 | if ( useBatch ) {↵ | | 45 | if ( useBatch ) {↵
|
44 | session.getBatcher().abortBatch( sqle );↵ | | 46 | session.getBatcher().abortBatch( sqle );↵
|
45 | }↵ | | 47 | }↵
|
46 | throw sqle;↵ | | 48 | throw sqle;↵
|
47 | }↵ | | 49 | }↵
|
48 | finally {↵ | | 50 | finally {↵
|
49 | if ( !useBatch ) {↵ | | 51 | if ( !useBatch ) {↵
|
50 | session.getBatcher().closeStatement( st );↵ | | 52 | session.getBatcher().closeStatement( st );↵
|
51 | ↵ | | 53 | }↵
|
| | | 54 | }↵
|
| | | 55 | count++;↵
|
52 | | | 56 |
|