-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-6682 add support for oracle "bitand" function to Oracle Dialect
- Loading branch information
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
hibernate-core/src/test/java/org/hibernate/test/math/Math.hbm.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,21 @@ | |||
<?xml version="1.0"?> | |||
|
|||
<!DOCTYPE hibernate-mapping PUBLIC | |||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" | |||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> | |||
|
|||
|
|||
<hibernate-mapping package="org.hibernate.test.math"> | |||
|
|||
<class name="MathEntity" table="MathEntity"> | |||
<id name="id"> | |||
<generator class="native"/> | |||
</id> | |||
|
|||
|
|||
<property name="value"> | |||
<column name="value" not-null="true" /> | |||
</property> | |||
</class> | |||
|
|||
</hibernate-mapping> |
48 changes: 48 additions & 0 deletions
48
hibernate-core/src/test/java/org/hibernate/test/math/MathEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,48 @@ | |||
/* | |||
* Hibernate, Relational Persistence for Idiomatic Java | |||
* | |||
* JBoss, Home of Professional Open Source | |||
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors | |||
* as indicated by the @authors tag. All rights reserved. | |||
* See the copyright.txt in the distribution for a | |||
* full listing of individual contributors. | |||
* | |||
* 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, v. 2.1. | |||
* This program is distributed in the hope that it will be useful, but WITHOUT A | |||
* 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, | |||
* v.2.1 along with this distribution; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301, USA. | |||
*/ | |||
package org.hibernate.test.math; | |||
|
|||
/** | |||
* @author Brett Meyer | |||
*/ | |||
public class MathEntity { | |||
|
|||
private Long id; | |||
|
|||
private int value; | |||
|
|||
public Long getId() { | |||
return id; | |||
} | |||
|
|||
public void setId(Long id) { | |||
this.id = id; | |||
} | |||
|
|||
public int getValue() { | |||
return value; | |||
} | |||
|
|||
public void setValue(int value) { | |||
this.value = value; | |||
} | |||
|
|||
} |
67 changes: 67 additions & 0 deletions
67
hibernate-core/src/test/java/org/hibernate/test/math/MathTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,67 @@ | |||
/* | |||
* Hibernate, Relational Persistence for Idiomatic Java | |||
* | |||
* JBoss, Home of Professional Open Source | |||
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors | |||
* as indicated by the @authors tag. All rights reserved. | |||
* See the copyright.txt in the distribution for a | |||
* full listing of individual contributors. | |||
* | |||
* 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, v. 2.1. | |||
* This program is distributed in the hope that it will be useful, but WITHOUT A | |||
* 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, | |||
* v.2.1 along with this distribution; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301, USA. | |||
*/ | |||
package org.hibernate.test.math; | |||
|
|||
import static org.junit.Assert.assertEquals; | |||
|
|||
import org.hibernate.Session; | |||
import org.hibernate.dialect.H2Dialect; | |||
import org.hibernate.dialect.Oracle8iDialect; | |||
import org.hibernate.testing.RequiresDialect; | |||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; | |||
import org.junit.Test; | |||
|
|||
/** | |||
* @author Brett Meyer | |||
*/ | |||
@RequiresDialect( value = { Oracle8iDialect.class, H2Dialect.class } ) | |||
public class MathTest extends BaseCoreFunctionalTestCase { | |||
|
|||
@Override | |||
public String[] getMappings() { | |||
return new String[]{"math/Math.hbm.xml"}; | |||
} | |||
|
|||
@Test | |||
public void testBitAnd() { | |||
MathEntity me = new MathEntity(); | |||
me.setValue( 5 ); | |||
|
|||
Session s = openSession(); | |||
s.beginTransaction(); | |||
Long id = (Long) s.save( me ); | |||
s.getTransaction().commit(); | |||
s.close(); | |||
|
|||
s = openSession(); | |||
s.beginTransaction(); | |||
int value1 = (int)s.createQuery( "select bitand(m.value,0) from MathEntity m where m.id=" + id ).uniqueResult(); | |||
int value2 = (int)s.createQuery( "select bitand(m.value,2) from MathEntity m where m.id=" + id ).uniqueResult(); | |||
int value3 = (int)s.createQuery( "select bitand(m.value,3) from MathEntity m where m.id=" + id ).uniqueResult(); | |||
s.getTransaction().commit(); | |||
s.close(); | |||
|
|||
assertEquals(value1, 0); | |||
assertEquals(value2, 0); | |||
assertEquals(value3, 1); | |||
} | |||
|
|||
} |