01: package net.sourceforge.jaxor.impl;
02:
03: import net.sourceforge.jaxor.EntityChange;
04: import net.sourceforge.jaxor.api.EntityInterface;
05:
06: import java.sql.PreparedStatement;
07: import java.sql.Connection;
08: import java.sql.SQLException;
09:
10: /**
11: * Created By: Mike
12: * Date: Feb 12, 2004
13: * Time: 9:41:08 PM
14: *
15: * Last Checkin: $Author: mrettig $
16: * Date: $Date: 2004/02/13 04:48:27 $
17: * Revision: $Revision: 1.1 $
18: */
19: public class InsertEntityChange extends EntityChange {
20:
21: public InsertEntityChange(EntityInterface entity) {
22: super (entity);
23: }
24:
25: public InsertEntityChange(int changeNumber, EntityInterface entity) {
26: super (changeNumber, entity);
27: }
28:
29: public PreparedStatement execute(Connection conn)
30: throws SQLException {
31: return getSqlAdapter().getInsertPreparedStatement(conn);
32: }
33:
34: public boolean isBatchable() {
35: return true;
36: }
37:
38: public void addToBatch(PreparedStatement stmt) throws SQLException {
39: getSqlAdapter().addToInsertBatch(stmt);
40: stmt.addBatch();
41: }
42:
43: public void beforeFlush() {
44: getSqlAdapter().beforeInsert();
45: }
46:
47: public void flush(Connection conn) {
48: getSqlAdapter().insert(conn);
49: }
50:
51: public void afterFlush() {
52: getSqlAdapter().afterInsert();
53: }
54: }
|