Hi, I have a simple class and about 12 which extends from it. An example is here.
Code:
@Entity
@Table(name="HwAtCommand")
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Command extends DomainObject implements Comparable<Command>{
private String targetAcuIp;
@Temporal(TemporalType.TIMESTAMP)
private Date timeStamp;
@Enumerated
private CommandType type;
private int priority=0;
private boolean send = false;
@Temporal(TemporalType.TIMESTAMP)
private Date lastAttempt;
private int attemptCount;
public abstract PreparedStatement generateSQLStatement(Connection conn)
throws SQLException;
....getters and setter for properties
}
@Entity
@Table(name = "hwIdentifierCommand")
@PrimaryKeyJoinColumn(name = "parentId")
public class IdentifierCommand extends Command {
public static final String CREATE_COMMAND = "insert into sqminikey(x'09') values (sqminikey(?), ?, 'no');";
public static final String REPLACE_COMMAND = "replace into sqminikey(x'09') values (sqminikey(?), ?, 'no');";
public static final String REMOVE_COMMAND = "delete from sqminikey(x'09') where sqminikey==?;";
private byte[] identifierSerialNumber;
private Long subjectId;
.... methods
}
My problem is, that in a system with about 1000 people put in database, many operation may need to persist about tousands of new instances of some commands. This seems to be a very thin bottleneck for my application, cause as i tried to simply persist 2000 instances to MS SQL Server, it took over 3 minutes. 3 minutes for 2000 instances persist is in my opinion too much. I know it's not only 2000 inserts, it is probably double that much, but still database on the device, which is simple implementation of SQLite handles 2000 inserts in about 5 min, a there's bottle neck of small ram, arm processor and writing to MMC card. The worst is that there may occure companies with 10 000 people and more, a in the worst case, about 100000 instances of Command may be need to persist.
Is the time for persisting 2000 instances normal? Is there any way to speed this "bulk insert" up besides using JDBC(I know this should speed things up but I would loose independence on SQL provider and maybe have some problem with generating primary keys )? I am not using any second level caching, but i think this shouldn't have influence on the persist operation, only on get operation.
Does somebody have any ideas?