Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into HHH-2394
Browse files Browse the repository at this point in the history
  • Loading branch information
rworsnop committed May 23, 2012
2 parents c3e8362 + 4b74517 commit 7e8d09d
Show file tree
Hide file tree
Showing 28 changed files with 336 additions and 78 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/target
/build
*/build
testdb

# IntelliJ specific files/directories
out
Expand Down
25 changes: 25 additions & 0 deletions databases/derby/matrix.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. 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 Inc.
*
* 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
*/

jdbcDependency "org.apache.derby:derby:10.8.2.2"
40 changes: 40 additions & 0 deletions databases/derby/resources/hibernate.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Hibernate, Relational Persistence for Idiomatic Java
#
# Copyright (c) 2011, Red Hat Inc. 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 Inc.
#
# 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
#

hibernate.dialect org.hibernate.dialect.DerbyTenSevenDialect
hibernate.connection.driver_class org.apache.derby.jdbc.EmbeddedDriver
hibernate.connection.url jdbc:derby:testdb;create=true
hibernate.connection.username sa

hibernate.connection.pool_size 5

hibernate.show_sql true
hibernate.format_sql true

hibernate.max_fetch_depth 5

hibernate.cache.region_prefix hibernate.test
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory


2 changes: 1 addition & 1 deletion databases/postgresql84/resources/hibernate.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Boston, MA 02110-1301 USA
#

hibernate.dialect org.hibernate.dialect.PostgreSQLDialect
hibernate.dialect org.hibernate.dialect.PostgreSQL82Dialect
hibernate.connection.driver_class org.postgresql.Driver
hibernate.connection.url jdbc:postgresql://localhost/hibernate
hibernate.connection.username hibernate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,13 @@
<entry>org.hibernate.dialect.PointbaseDialect</entry>
</row>
<row>
<entry>PostgreSQL</entry>
<entry>org.hibernate.dialect.PostgreSQLDialect</entry>
<entry>PostgreSQL 8.1</entry>
<entry>org.hibernate.dialect.PostgreSQL81Dialect</entry>
</row>
<row>
<entry>PostgreSQL 8.2 and later</entry>
<entry>org.hibernate.dialect.PostgreSQL82Dialect</entry>
</row>
<row>
<entry>Progress</entry>
<entry>org.hibernate.dialect.ProgressDialect</entry>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=1800
hibernate.c3p0.max_statements=50
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=1800
hibernate.c3p0.max_statements=50
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect</programlisting>
hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect</programlisting>

<para>For use inside an application server, you should almost always
configure Hibernate to obtain connections from an application server
Expand Down Expand Up @@ -275,7 +275,7 @@ hibernate.transaction.factory_class = \
org.hibernate.transaction.JTATransactionFactory
hibernate.transaction.manager_lookup_class = \
org.hibernate.transaction.JBossTransactionManagerLookup
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect</programlisting>
hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect</programlisting>

<para>JDBC connections obtained from a JNDI datasource will automatically
participate in the container-managed transactions of the application
Expand Down Expand Up @@ -975,11 +975,15 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect</programlisting>
</row>

<row>
<entry>PostgreSQL</entry>
<entry>PostgreSQL 8.1</entry>

<entry><literal>org.hibernate.dialect.PostgreSQLDialect</literal></entry>
<entry><literal>org.hibernate.dialect.PostgreSQL81Dialect</literal></entry>
</row>
<row>
<entry>PostgreSQL 8.2 and later</entry>

<entry><literal>org.hibernate.dialect.PostgreSQL82Dialect</literal></entry>
</row>
<row>
<entry>MySQL5</entry>

Expand Down Expand Up @@ -1023,11 +1027,16 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect</programlisting>
</row>

<row>
<entry>Sybase</entry>
<entry>Sybase ASE 15.5</entry>

<entry><literal>org.hibernate.dialect.SybaseASE15Dialect</literal></entry>
</row>

<row>
<entry>Sybase ASE 15.7</entry>

<entry><literal>org.hibernate.dialect.SybaseASE157Dialect</literal></entry>
</row>
<row>
<entry>Sybase Anywhere</entry>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,24 @@
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Loader;
import org.hibernate.annotations.NaturalIdCache;
import org.hibernate.annotations.OptimisticLockType;
import org.hibernate.annotations.OptimisticLocking;
import org.hibernate.annotations.Persister;
import org.hibernate.annotations.Polymorphism;
import org.hibernate.annotations.PolymorphismType;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.RowId;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.SQLInsert;
import org.hibernate.annotations.SQLUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;
import org.hibernate.annotations.Subselect;
import org.hibernate.annotations.Synchronize;
import org.hibernate.annotations.Tables;
Expand Down Expand Up @@ -153,24 +158,48 @@ public EntityBinder(
bindHibernateAnnotation( hibAnn );
}

@SuppressWarnings("SimplifiableConditionalExpression")
private void bindHibernateAnnotation(org.hibernate.annotations.Entity hibAnn) {
{
final DynamicInsert dynamicInsertAnn = annotatedClass.getAnnotation( DynamicInsert.class );
this.dynamicInsert = dynamicInsertAnn == null
? ( hibAnn == null ? false : hibAnn.dynamicInsert() )
: dynamicInsertAnn.value();
}

{
final DynamicUpdate dynamicUpdateAnn = annotatedClass.getAnnotation( DynamicUpdate.class );
this.dynamicUpdate = dynamicUpdateAnn == null
? ( hibAnn == null ? false : hibAnn.dynamicUpdate() )
: dynamicUpdateAnn.value();
}

{
final SelectBeforeUpdate selectBeforeUpdateAnn = annotatedClass.getAnnotation( SelectBeforeUpdate.class );
this.selectBeforeUpdate = selectBeforeUpdateAnn == null
? ( hibAnn == null ? false : hibAnn.selectBeforeUpdate() )
: selectBeforeUpdateAnn.value();
}

{
final OptimisticLocking optimisticLockingAnn = annotatedClass.getAnnotation( OptimisticLocking.class );
this.optimisticLockType = optimisticLockingAnn == null
? ( hibAnn == null ? OptimisticLockType.VERSION : hibAnn.optimisticLock() )
: optimisticLockingAnn.type();
}

{
final Polymorphism polymorphismAnn = annotatedClass.getAnnotation( Polymorphism.class );
this.polymorphismType = polymorphismAnn == null
? ( hibAnn == null ? PolymorphismType.IMPLICIT : hibAnn.polymorphism() )
: polymorphismAnn.type();
}

if ( hibAnn != null ) {
dynamicInsert = hibAnn.dynamicInsert();
dynamicUpdate = hibAnn.dynamicUpdate();
optimisticLockType = hibAnn.optimisticLock();
selectBeforeUpdate = hibAnn.selectBeforeUpdate();
polymorphismType = hibAnn.polymorphism();
// used later in bind for logging
explicitHibernateEntityAnnotation = true;
//persister handled in bind
}
else {
//default values when the annotation is not there
dynamicInsert = false;
dynamicUpdate = false;
optimisticLockType = OptimisticLockType.VERSION;
polymorphismType = PolymorphismType.IMPLICIT;
selectBeforeUpdate = false;
}
}

private void bindEjb3Annotation(Entity ejb3Ann) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.engine.spi.TypedValue;

Expand Down Expand Up @@ -57,7 +58,7 @@ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
if ( columns.length != 1 ) {
throw new HibernateException( "ilike may only be used with single-column properties" );
}
if ( dialect instanceof PostgreSQLDialect ) {
if ( dialect instanceof PostgreSQLDialect || dialect instanceof PostgreSQL81Dialect) {
return columns[0] + " ilike ?";
}
else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, Red Hat Inc. 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 Inc.
*
* 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.test.annotations.entity;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.OptimisticLock;
import org.hibernate.annotations.OptimisticLockType;
import org.hibernate.annotations.OptimisticLocking;
import org.hibernate.annotations.Polymorphism;
import org.hibernate.annotations.PolymorphismType;
import org.hibernate.annotations.SelectBeforeUpdate;
import org.hibernate.annotations.Type;

/**
* Mapping following lines of {@link Forest}, but using the replacements for the now deprecated
* {@link org.hibernate.annotations.Entity} annotation.
*
* @author Steve Ebersole
*/
@Entity
@DynamicInsert
@DynamicUpdate
@SelectBeforeUpdate
@OptimisticLocking( type = OptimisticLockType.ALL )
@Polymorphism( type = PolymorphismType.EXPLICIT )
public class Forest2 {
private Integer id;
private String name;
private String longDescription;

@Id
@GeneratedValue
public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@OptimisticLock(excluded=true)
@Type(type = "text")
public String getLongDescription() {
return longDescription;
}

public void setLongDescription(String longDescription) {
this.longDescription = longDescription;
}
}
Loading

0 comments on commit 7e8d09d

Please sign in to comment.