Performance tests

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@15601 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Adam Warski 2008-11-20 13:09:44 +00:00
parent 3ad01d08f5
commit 266fbedbd3
10 changed files with 665 additions and 110 deletions

View File

@ -29,10 +29,13 @@ import javax.persistence.EntityManagerFactory;
import org.hibernate.envers.AuditReader;
import org.hibernate.envers.AuditReaderFactory;
import org.hibernate.envers.event.AuditEventListener;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterClass;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.event.*;
/**
* @author Adam Warski (adam at warski dot org)
@ -42,22 +45,50 @@ public abstract class AbstractEntityTest {
private EntityManager entityManager;
private AuditReader auditReader;
private Ejb3Configuration cfg;
private boolean audited;
public abstract void configure(Ejb3Configuration cfg);
@BeforeMethod
public void newEntityManager() {
if (entityManager != null) {
entityManager.close();
protected void initListeners() {
AuditEventListener listener = new AuditEventListener();
cfg.getEventListeners().setPostInsertEventListeners(new PostInsertEventListener[] { listener });
cfg.getEventListeners().setPostUpdateEventListeners(new PostUpdateEventListener[] { listener });
cfg.getEventListeners().setPostDeleteEventListeners(new PostDeleteEventListener[] { listener });
cfg.getEventListeners().setPreCollectionUpdateEventListeners(new PreCollectionUpdateEventListener[] { listener });
cfg.getEventListeners().setPreCollectionRemoveEventListeners(new PreCollectionRemoveEventListener[] { listener });
cfg.getEventListeners().setPostCollectionRecreateEventListeners(new PostCollectionRecreateEventListener[] { listener });
}
private void closeEntityManager() {
if (entityManager != null) {
entityManager.close();
entityManager = null;
}
}
@BeforeMethod
public void newEntityManager() {
closeEntityManager();
entityManager = emf.createEntityManager();
if (audited) {
auditReader = AuditReaderFactory.get(entityManager);
}
}
@BeforeClass
public void init() throws IOException {
init(true);
}
protected void init(boolean audited) throws IOException {
this.audited = audited;
cfg = new Ejb3Configuration();
if (audited) {
initListeners();
}
cfg.configure("hibernate.test.cfg.xml");
configure(cfg);
emf = cfg.buildEntityManagerFactory();
@ -65,6 +96,12 @@ public abstract class AbstractEntityTest {
newEntityManager();
}
@AfterClass
public void close() {
closeEntityManager();
emf.close();
}
public EntityManager getEntityManager() {
return entityManager;
}

View File

@ -24,7 +24,10 @@
package org.hibernate.envers.test.performance;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.tools.Pair;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
/**
* @author Adam Warski (adam at warski dot org)
@ -34,49 +37,72 @@ public abstract class AbstractPerformanceTest extends AbstractEntityTest {
return (milliseconds/1000) + "." + (milliseconds%1000);
}
protected long measureTime(Runnable r) {
long start = System.currentTimeMillis();
r.run();
return System.currentTimeMillis() - start;
protected abstract void doTest();
private void printResults(long unaudited, long audited) {
System.out.println("Unaudited: " + getSecondsString(unaudited));
System.out.println(" Audited: " + getSecondsString(audited));
System.out.println(" Delta: " + getSecondsString(audited-unaudited));
System.out.println(" Factor: " + (double)audited/unaudited);
}
protected abstract Pair<Long, Long> doTest();
private long startTime;
private long runTotal;
protected abstract String getName();
private long totalUnversioned;
private long totalVersioned;
private void printResults(long unversioned, long versioned) {
System.out.println("Unversioned: " + getSecondsString(unversioned));
System.out.println(" Versioned: " + getSecondsString(versioned));
System.out.println(" Delta: " + getSecondsString(versioned-unversioned));
System.out.println(" Factor: " + (double)versioned/unversioned);
protected void start() {
startTime = System.currentTimeMillis();
}
private void test(boolean count) {
Pair<Long, Long> result = doTest();
long unversioned = result.getFirst();
long versioned = result.getSecond();
totalUnversioned += unversioned;
totalVersioned += versioned;
printResults(unversioned, versioned);
protected void stop() {
long stopTime = System.currentTimeMillis();
runTotal += stopTime - startTime;
}
public void run(int numberOfRuns) {
protected void reset() {
runTotal = 0;
}
public long run(int numberOfRuns, List<Long> results) {
long total = 0;
for (int i=0; i<=numberOfRuns; i++) {
System.out.println("");
System.out.println(getName() + " TEST, RUN " + i);
test(i != 0);
System.out.println();
System.out.println("RUN " + i);
reset();
doTest();
results.add(runTotal);
total += runTotal;
newEntityManager();
/*System.gc();
System.gc();
System.gc();
System.out.println(Runtime.getRuntime().freeMemory() + ", " + Runtime.getRuntime().totalMemory() + ", "
+ (Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()));*/
}
totalUnversioned /= numberOfRuns;
totalVersioned /= numberOfRuns;
return total;
}
System.out.println("");
System.out.println(getName() + " TEST, AVERAGE");
printResults(totalUnversioned, totalVersioned);
public void test(int numberOfRuns) throws IOException {
List<Long> unauditedRuns = new ArrayList<Long>();
List<Long> auditedRuns = new ArrayList<Long>();
init(true);
long audited = run(numberOfRuns, auditedRuns);
close();
init(false);
long unaudited = run(numberOfRuns, unauditedRuns);
close();
for (int i=0; i<=numberOfRuns; i++) {
System.out.println("RUN " + i);
printResults(unauditedRuns.get(i), auditedRuns.get(i));
System.out.println();
}
System.out.println("TOTAL");
printResults(unaudited, audited);
}
}

View File

@ -0,0 +1,105 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.performance;
import java.io.IOException;
import java.util.Date;
import java.util.HashSet;
import javax.persistence.EntityManager;
import org.hibernate.envers.test.performance.complex.RootEntity;
import org.hibernate.envers.test.performance.complex.ChildEntity2;
import org.hibernate.envers.test.performance.complex.ChildEntity1;
import org.hibernate.ejb.Ejb3Configuration;
/**
* @author Adam Warski (adam at warski dot org)
*/
public class ComplexInsertPerformance extends AbstractPerformanceTest {
public void configure(Ejb3Configuration cfg) {
cfg.addAnnotatedClass(RootEntity.class);
cfg.addAnnotatedClass(ChildEntity1.class);
cfg.addAnnotatedClass(ChildEntity2.class);
}
private final static int NUMBER_INSERTS = 100;
private long idCounter = 0;
private ChildEntity2 createChildEntity2() {
ChildEntity2 ce = new ChildEntity2();
ce.setId(idCounter++);
ce.setNumber(12345678);
ce.setData("some data, not really meaningful");
ce.setStrings(new HashSet<String>());
ce.getStrings().add("aaa");
ce.getStrings().add("bbb");
ce.getStrings().add("ccc");
return ce;
}
private ChildEntity1 createChildEntity1() {
ChildEntity1 ce = new ChildEntity1();
ce.setId(idCounter++);
ce.setData1("xxx");
ce.setData2("yyy");
ce.setChild1(createChildEntity2());
ce.setChild2(createChildEntity2());
return ce;
}
protected void doTest() {
for (int i=0; i<NUMBER_INSERTS; i++) {
newEntityManager();
EntityManager entityManager = getEntityManager();
entityManager.getTransaction().begin();
RootEntity re = new RootEntity();
re.setId(idCounter++);
re.setData1("data1");
re.setData2("data2");
re.setDate1(new Date());
re.setNumber1(123);
re.setNumber2(456);
re.setChild1(createChildEntity1());
re.setChild2(createChildEntity1());
re.setChild3(createChildEntity1());
start();
entityManager.persist(re);
entityManager.getTransaction().commit();
stop();
}
}
public static void main(String[] args) throws IOException {
ComplexInsertPerformance insertsPerformance = new ComplexInsertPerformance();
insertsPerformance.test(3);
}
}

View File

@ -0,0 +1,59 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.performance;
import java.io.IOException;
import javax.persistence.EntityManager;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.ejb.Ejb3Configuration;
/**
* @author Adam Warski (adam at warski dot org)
*/
public class InsertsOneTransactionPerformance extends AbstractPerformanceTest {
public void configure(Ejb3Configuration cfg) {
cfg.addAnnotatedClass(StrTestEntity.class);
}
private final static int NUMBER_INSERTS = 5000;
protected void doTest() {
EntityManager entityManager = getEntityManager();
entityManager.getTransaction().begin();
start();
for (int i=0; i<NUMBER_INSERTS; i++) {
entityManager.persist(new StrTestEntity("x" + i));
}
entityManager.getTransaction().commit();
stop();
}
public static void main(String[] args) throws IOException {
InsertsOneTransactionPerformance insertsOneTransactionPerformance = new InsertsOneTransactionPerformance();
insertsOneTransactionPerformance.test(3);
}
}

View File

@ -27,8 +27,6 @@ import java.io.IOException;
import javax.persistence.EntityManager;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
import org.hibernate.envers.tools.Pair;
import org.hibernate.ejb.Ejb3Configuration;
@ -38,43 +36,25 @@ import org.hibernate.ejb.Ejb3Configuration;
public class InsertsPerformance extends AbstractPerformanceTest {
public void configure(Ejb3Configuration cfg) {
cfg.addAnnotatedClass(StrTestEntity.class);
cfg.addAnnotatedClass(UnversionedStrTestEntity.class);
}
private final static int NUMBER_INSERTS = 1000;
private final static int NUMBER_INSERTS = 500;
private void insertUnversioned() {
EntityManager entityManager = getEntityManager();
protected void doTest() {
for (int i=0; i<NUMBER_INSERTS; i++) {
entityManager.getTransaction().begin();
entityManager.persist(new UnversionedStrTestEntity("x" + i));
entityManager.getTransaction().commit();
}
}
private void insertVersioned() {
newEntityManager();
EntityManager entityManager = getEntityManager();
for (int i=0; i<NUMBER_INSERTS; i++) {
entityManager.getTransaction().begin();
start();
entityManager.persist(new StrTestEntity("x" + i));
entityManager.getTransaction().commit();
stop();
}
}
protected Pair<Long, Long> doTest() {
long unversioned = measureTime(new Runnable() { public void run() { insertUnversioned(); } });
long versioned = measureTime(new Runnable() { public void run() { insertVersioned(); } });
return Pair.make(unversioned, versioned);
}
protected String getName() {
return "INSERTS";
}
public static void main(String[] args) throws IOException {
InsertsPerformance insertsPerformance = new InsertsPerformance();
insertsPerformance.init();
insertsPerformance.run(10);
insertsPerformance.test(3);
}
}

View File

@ -30,9 +30,6 @@ import java.util.Random;
import javax.persistence.EntityManager;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
import org.hibernate.envers.tools.Pair;
import org.hibernate.ejb.Ejb3Configuration;
/**
@ -41,71 +38,46 @@ import org.hibernate.ejb.Ejb3Configuration;
public class UpdatesPerformance extends AbstractPerformanceTest {
public void configure(Ejb3Configuration cfg) {
cfg.addAnnotatedClass(StrTestEntity.class);
cfg.addAnnotatedClass(UnversionedStrTestEntity.class);
}
private final static int NUMBER_UPDATES = 1000;
private final static int NUMBER_UPDATES = 500;
private final static int NUMBER_ENTITIES = 10;
private Random random = new Random();
private List<Integer> unversioned_ids = new ArrayList<Integer>();
private List<Integer> versioned_ids = new ArrayList<Integer>();
private List<Integer> ids = new ArrayList<Integer>();
public void setup() {
private void setup() {
EntityManager entityManager = getEntityManager();
entityManager.getTransaction().begin();
for (int i=0; i<NUMBER_ENTITIES; i++) {
UnversionedStrTestEntity testEntity = new UnversionedStrTestEntity("x" + i);
entityManager.persist(testEntity);
unversioned_ids.add(testEntity.getId());
}
for (int i=0; i<NUMBER_ENTITIES; i++) {
StrTestEntity testEntity = new StrTestEntity("x" + i);
entityManager.persist(testEntity);
versioned_ids.add(testEntity.getId());
ids.add(testEntity.getId());
}
entityManager.getTransaction().commit();
}
private void updateUnversioned() {
EntityManager entityManager = getEntityManager();
for (int i=0; i<NUMBER_UPDATES; i++) {
entityManager.getTransaction().begin();
Integer id = unversioned_ids.get(random.nextInt(NUMBER_ENTITIES));
UnversionedStrTestEntity testEntity = entityManager.find(UnversionedStrTestEntity.class, id);
testEntity.setStr("z" + i);
entityManager.getTransaction().commit();
}
}
protected void doTest() {
setup();
private void updateVersioned() {
EntityManager entityManager = getEntityManager();
for (int i=0; i<NUMBER_UPDATES; i++) {
newEntityManager();
EntityManager entityManager = getEntityManager();
entityManager.getTransaction().begin();
Integer id = versioned_ids.get(random.nextInt(NUMBER_ENTITIES));
Integer id = ids.get(random.nextInt(NUMBER_ENTITIES));
start();
StrTestEntity testEntity = entityManager.find(StrTestEntity.class, id);
testEntity.setStr("z" + i);
entityManager.getTransaction().commit();
stop();
}
}
protected Pair<Long, Long> doTest() {
long unversioned = measureTime(new Runnable() { public void run() { updateUnversioned(); } });
long versioned = measureTime(new Runnable() { public void run() { updateVersioned(); } });
return Pair.make(unversioned, versioned);
}
protected String getName() {
return "UPDATES";
}
public static void main(String[] args) throws IOException {
UpdatesPerformance updatesPerformance = new UpdatesPerformance();
updatesPerformance.init();
updatesPerformance.setup();
updatesPerformance.run(10);
updatesPerformance.test(3);
}
}

View File

@ -0,0 +1,113 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.performance.complex;
import org.hibernate.envers.Audited;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.CascadeType;
/**
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Audited
public class ChildEntity1 {
@Id
private Long id;
@ManyToOne(cascade = CascadeType.ALL)
private ChildEntity2 child1;
@ManyToOne(cascade = CascadeType.ALL)
private ChildEntity2 child2;
private String data1;
private String data2;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public ChildEntity2 getChild1() {
return child1;
}
public void setChild1(ChildEntity2 child1) {
this.child1 = child1;
}
public ChildEntity2 getChild2() {
return child2;
}
public void setChild2(ChildEntity2 child2) {
this.child2 = child2;
}
public String getData1() {
return data1;
}
public void setData1(String data1) {
this.data1 = data1;
}
public String getData2() {
return data2;
}
public void setData2(String data2) {
this.data2 = data2;
}
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ChildEntity1)) return false;
ChildEntity1 that = (ChildEntity1) o;
if (data1 != null ? !data1.equals(that.data1) : that.data1 != null) return false;
if (data2 != null ? !data2.equals(that.data2) : that.data2 != null) return false;
if (id != null ? !id.equals(that.id) : that.id != null) return false;
return true;
}
public int hashCode() {
int result;
result = (id != null ? id.hashCode() : 0);
result = 31 * result + (data1 != null ? data1.hashCode() : 0);
result = 31 * result + (data2 != null ? data2.hashCode() : 0);
return result;
}
}

View File

@ -0,0 +1,102 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.performance.complex;
import org.hibernate.envers.Audited;
import org.hibernate.annotations.CollectionOfElements;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.Set;
/**
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Audited
public class ChildEntity2 {
@Id
private Long id;
private String data;
private Integer number;
@CollectionOfElements
private Set<String> strings;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public Integer getNumber() {
return number;
}
public void setNumber(Integer number) {
this.number = number;
}
public Set<String> getStrings() {
return strings;
}
public void setStrings(Set<String> strings) {
this.strings = strings;
}
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ChildEntity2)) return false;
ChildEntity2 that = (ChildEntity2) o;
if (data != null ? !data.equals(that.data) : that.data != null) return false;
if (id != null ? !id.equals(that.id) : that.id != null) return false;
if (number != null ? !number.equals(that.number) : that.number != null) return false;
return true;
}
public int hashCode() {
int result;
result = (id != null ? id.hashCode() : 0);
result = 31 * result + (data != null ? data.hashCode() : 0);
result = 31 * result + (number != null ? number.hashCode() : 0);
return result;
}
}

View File

@ -0,0 +1,159 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.performance.complex;
import org.hibernate.envers.Audited;
import javax.persistence.*;
import java.util.Date;
/**
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Audited
public class RootEntity {
@Id
private Long id;
private String data1;
private String data2;
private Integer number1;
private Integer number2;
@Temporal(TemporalType.TIMESTAMP)
private Date date1;
@ManyToOne(cascade = CascadeType.ALL)
private ChildEntity1 child1;
@ManyToOne(cascade = CascadeType.ALL)
private ChildEntity1 child2;
@ManyToOne(cascade = CascadeType.ALL)
private ChildEntity1 child3;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getData1() {
return data1;
}
public void setData1(String data1) {
this.data1 = data1;
}
public String getData2() {
return data2;
}
public void setData2(String data2) {
this.data2 = data2;
}
public Integer getNumber1() {
return number1;
}
public void setNumber1(Integer number1) {
this.number1 = number1;
}
public Integer getNumber2() {
return number2;
}
public void setNumber2(Integer number2) {
this.number2 = number2;
}
public Date getDate1() {
return date1;
}
public void setDate1(Date date1) {
this.date1 = date1;
}
public ChildEntity1 getChild1() {
return child1;
}
public void setChild1(ChildEntity1 child1) {
this.child1 = child1;
}
public ChildEntity1 getChild2() {
return child2;
}
public void setChild2(ChildEntity1 child2) {
this.child2 = child2;
}
public ChildEntity1 getChild3() {
return child3;
}
public void setChild3(ChildEntity1 child3) {
this.child3 = child3;
}
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof RootEntity)) return false;
RootEntity that = (RootEntity) o;
if (data1 != null ? !data1.equals(that.data1) : that.data1 != null) return false;
if (data2 != null ? !data2.equals(that.data2) : that.data2 != null) return false;
if (date1 != null ? !date1.equals(that.date1) : that.date1 != null) return false;
if (id != null ? !id.equals(that.id) : that.id != null) return false;
if (number1 != null ? !number1.equals(that.number1) : that.number1 != null) return false;
if (number2 != null ? !number2.equals(that.number2) : that.number2 != null) return false;
return true;
}
public int hashCode() {
int result;
result = (id != null ? id.hashCode() : 0);
result = 31 * result + (data1 != null ? data1.hashCode() : 0);
result = 31 * result + (data2 != null ? data2.hashCode() : 0);
result = 31 * result + (number1 != null ? number1.hashCode() : 0);
result = 31 * result + (number2 != null ? number2.hashCode() : 0);
result = 31 * result + (date1 != null ? date1.hashCode() : 0);
return result;
}
}

View File

@ -17,13 +17,15 @@
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<!--<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!--<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="connection.url">jdbc:mysql:///hibernate_tests?useUnicode=true&amp;characterEncoding=UTF-8</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>-->
<property name="connection.password"></property>
<event type="post-insert">
<property name="hibernate.jdbc.batch_size">100</property>-->
<!--<event type="post-insert">
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
<event type="post-update">
@ -40,6 +42,6 @@
</event>
<event type="post-collection-recreate">
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
</event>-->
</session-factory>
</hibernate-configuration>