I have a sample controller that inserts my objects and it works perfectly. Only problem is that when it creates the entries the first time, it appears that it only updates them the next time and does not actually create new entries. Every time I run my app, I would expect to see a new row - instead I see the same row over and over. My ID is annotated to auto generate, but no such luck...
Code:
Code:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
Transaction transaction = session.beginTransaction();
AuditEvent ae = new AuditEvent("SUCCES", "Launching web app");
session.save(ae);
model
Code:
@Entity
@Table(name = "Auditing")
public class AuditEvent implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id = null;
@Column(name = "status")
private String status;
@Column(name = "description")
private String description;
Just in case, connection settings:
Code:
AnnotationConfiguration config = new AnnotationConfiguration();
config.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect");
config.setProperty("hibernate.connection.driver_class", "net.sourceforge.jtds.jdbc.Driver");
config.setProperty("hibernate.connection.url", "jdbc:jtds:sqlserver://localhost:3356/dev");
config.setProperty("hibernate.connection.username", "ami");
config.setProperty("hibernate.connection.password", "ami123");
config.setProperty("hibernate.connection.pool_size", "1");
config.setProperty("hibernate.connection.autocommit", "true");
config.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.NoCacheProvider");
config.setProperty("hibernate.hbm2ddl.auto", "create-drop");
config.setProperty("hibernate.show_sql", "true");
config.setProperty("hibernate.transaction.factory_class", "org.hibernate.transaction.JDBCTransactionFactory");
config.setProperty("hibernate.current_session_context_class", "thread");