HHH-8900 annotations OneToOne test fail with some sequence supporting
dialects Conflicts: hibernate-core/src/test/java/org/hibernate/test/annotations/onetoone/OneToOneTest.java
This commit is contained in:
parent
ae7d59529e
commit
af428a1273
|
@ -23,11 +23,14 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.onetoone;
|
package org.hibernate.test.annotations.onetoone;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.EmptyInterceptor;
|
import org.hibernate.EmptyInterceptor;
|
||||||
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
|
@ -42,10 +45,7 @@ import org.hibernate.test.annotations.Passport;
|
||||||
import org.hibernate.test.annotations.Ticket;
|
import org.hibernate.test.annotations.Ticket;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
|
@ -410,30 +410,34 @@ public class OneToOneTest extends BaseCoreFunctionalTestCase {
|
||||||
protected String[] getXmlFiles() {
|
protected String[] getXmlFiles() {
|
||||||
return new String[] { "org/hibernate/test/annotations/onetoone/orm.xml" };
|
return new String[] { "org/hibernate/test/annotations/onetoone/orm.xml" };
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
|
||||||
* Verifies that generated 'select' statement has desired number of joins
|
* Verifies that generated 'select' statement has desired number of joins
|
||||||
* @author Sharath Reddy
|
* @author Sharath Reddy
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class JoinCounter extends EmptyInterceptor {
|
class JoinCounter extends EmptyInterceptor {
|
||||||
|
|
||||||
private static final long serialVersionUID = -3689681272273261051L;
|
private static final long serialVersionUID = -3689681272273261051L;
|
||||||
|
|
||||||
private int expectedNumberOfJoins = 0;
|
private int expectedNumberOfJoins = 0;
|
||||||
|
private String nextValString;
|
||||||
|
|
||||||
public JoinCounter(int val) {
|
public JoinCounter(int val) {
|
||||||
super();
|
super();
|
||||||
this.expectedNumberOfJoins = val;
|
this.expectedNumberOfJoins = val;
|
||||||
|
try {
|
||||||
|
nextValString = getDialect().getSequenceNextValString("");
|
||||||
|
} catch (MappingException ex) {
|
||||||
|
nextValString = "nextval";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String onPrepareStatement(String sql) {
|
public String onPrepareStatement(String sql) {
|
||||||
int numberOfJoins = 0;
|
int numberOfJoins = 0;
|
||||||
if (sql.startsWith("select") & !sql.contains("nextval")) {
|
if (sql.startsWith("select") & !sql.contains(nextValString)) {
|
||||||
numberOfJoins = count(sql, "join");
|
numberOfJoins = count(sql, "join");
|
||||||
assertEquals( expectedNumberOfJoins, numberOfJoins );
|
assertEquals( sql, expectedNumberOfJoins, numberOfJoins );
|
||||||
}
|
}
|
||||||
|
|
||||||
return sql;
|
return sql;
|
||||||
|
@ -459,5 +463,5 @@ class JoinCounter extends EmptyInterceptor {
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue