HHH-3906 EJB-436 ANN-830 Move to JPA 2 API as a dependency
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@16523 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
2e377bbc08
commit
11668ca67c
|
@ -58,8 +58,8 @@
|
||||||
<artifactId>hibernate-commons-annotations</artifactId>
|
<artifactId>hibernate-commons-annotations</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.persistence</groupId>
|
<groupId>org.hibernate.java-persistence</groupId>
|
||||||
<artifactId>persistence-api</artifactId>
|
<artifactId>jpa-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javassist</groupId>
|
<groupId>javassist</groupId>
|
||||||
|
@ -96,9 +96,9 @@
|
||||||
<version>${version}</version>
|
<version>${version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.persistence</groupId>
|
<groupId>org.hibernate.java-persistence</groupId>
|
||||||
<artifactId>persistence-api</artifactId>
|
<artifactId>jpa-api</artifactId>
|
||||||
<version>1.0</version>
|
<version>2.0.Beta1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javassist</groupId>
|
<groupId>javassist</groupId>
|
||||||
|
|
|
@ -70,6 +70,7 @@ import javax.persistence.Table;
|
||||||
import javax.persistence.TableGenerator;
|
import javax.persistence.TableGenerator;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
|
|
||||||
import org.hibernate.AnnotationException;
|
import org.hibernate.AnnotationException;
|
||||||
import org.hibernate.AssertionFailure;
|
import org.hibernate.AssertionFailure;
|
||||||
|
@ -1238,7 +1239,9 @@ public final class AnnotationBinder {
|
||||||
}
|
}
|
||||||
else if ( joinColumns == null &&
|
else if ( joinColumns == null &&
|
||||||
( property.isAnnotationPresent( OneToMany.class )
|
( property.isAnnotationPresent( OneToMany.class )
|
||||||
|| property.isAnnotationPresent( CollectionOfElements.class ) ) ) {
|
|| property.isAnnotationPresent( CollectionOfElements.class ) //legacy Hibernate
|
||||||
|
|| property.isAnnotationPresent( ElementCollection.class )
|
||||||
|
) ) {
|
||||||
OneToMany oneToMany = property.getAnnotation( OneToMany.class );
|
OneToMany oneToMany = property.getAnnotation( OneToMany.class );
|
||||||
String mappedBy = oneToMany != null ?
|
String mappedBy = oneToMany != null ?
|
||||||
oneToMany.mappedBy() :
|
oneToMany.mappedBy() :
|
||||||
|
@ -1454,11 +1457,13 @@ public final class AnnotationBinder {
|
||||||
}
|
}
|
||||||
else if ( property.isAnnotationPresent( OneToMany.class )
|
else if ( property.isAnnotationPresent( OneToMany.class )
|
||||||
|| property.isAnnotationPresent( ManyToMany.class )
|
|| property.isAnnotationPresent( ManyToMany.class )
|
||||||
|| property.isAnnotationPresent( CollectionOfElements.class )
|
|| property.isAnnotationPresent( CollectionOfElements.class ) //legacy Hibernate
|
||||||
|
|| property.isAnnotationPresent( ElementCollection.class )
|
||||||
|| property.isAnnotationPresent( ManyToAny.class ) ) {
|
|| property.isAnnotationPresent( ManyToAny.class ) ) {
|
||||||
OneToMany oneToManyAnn = property.getAnnotation( OneToMany.class );
|
OneToMany oneToManyAnn = property.getAnnotation( OneToMany.class );
|
||||||
ManyToMany manyToManyAnn = property.getAnnotation( ManyToMany.class );
|
ManyToMany manyToManyAnn = property.getAnnotation( ManyToMany.class );
|
||||||
CollectionOfElements collectionOfElementsAnn = property.getAnnotation( CollectionOfElements.class );
|
ElementCollection elementCollectionAnn = property.getAnnotation( ElementCollection.class );
|
||||||
|
CollectionOfElements collectionOfElementsAnn = property.getAnnotation( CollectionOfElements.class ); //legacy hibernate
|
||||||
org.hibernate.annotations.IndexColumn indexAnn = property.getAnnotation(
|
org.hibernate.annotations.IndexColumn indexAnn = property.getAnnotation(
|
||||||
org.hibernate.annotations.IndexColumn.class
|
org.hibernate.annotations.IndexColumn.class
|
||||||
);
|
);
|
||||||
|
@ -1585,7 +1590,9 @@ public final class AnnotationBinder {
|
||||||
collectionBinder.setCascadeStrategy( getCascadeStrategy( oneToManyAnn.cascade(), hibernateCascade ) );
|
collectionBinder.setCascadeStrategy( getCascadeStrategy( oneToManyAnn.cascade(), hibernateCascade ) );
|
||||||
collectionBinder.setOneToMany( true );
|
collectionBinder.setOneToMany( true );
|
||||||
}
|
}
|
||||||
else if ( collectionOfElementsAnn != null ) {
|
else if ( elementCollectionAnn != null
|
||||||
|
|| collectionOfElementsAnn != null //Hibernate legacy
|
||||||
|
) {
|
||||||
for (Ejb3JoinColumn column : joinColumns) {
|
for (Ejb3JoinColumn column : joinColumns) {
|
||||||
if ( column.isSecondary() ) {
|
if ( column.isSecondary() ) {
|
||||||
throw new NotYetImplementedException( "Collections having FK in secondary table" );
|
throw new NotYetImplementedException( "Collections having FK in secondary table" );
|
||||||
|
@ -1593,8 +1600,11 @@ public final class AnnotationBinder {
|
||||||
}
|
}
|
||||||
collectionBinder.setFkJoinColumns( joinColumns );
|
collectionBinder.setFkJoinColumns( joinColumns );
|
||||||
mappedBy = "";
|
mappedBy = "";
|
||||||
|
final Class<?> targetElement = elementCollectionAnn != null ?
|
||||||
|
elementCollectionAnn.targetClass() :
|
||||||
|
collectionOfElementsAnn.targetElement();
|
||||||
collectionBinder.setTargetEntity(
|
collectionBinder.setTargetEntity(
|
||||||
mappings.getReflectionManager().toXClass( collectionOfElementsAnn.targetElement() )
|
mappings.getReflectionManager().toXClass( targetElement )
|
||||||
);
|
);
|
||||||
//collectionBinder.setCascadeStrategy( getCascadeStrategy( embeddedCollectionAnn.cascade(), hibernateCascade ) );
|
//collectionBinder.setCascadeStrategy( getCascadeStrategy( embeddedCollectionAnn.cascade(), hibernateCascade ) );
|
||||||
collectionBinder.setOneToMany( true );
|
collectionBinder.setOneToMany( true );
|
||||||
|
|
|
@ -38,6 +38,7 @@ import javax.persistence.JoinTable;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.MapKey;
|
import javax.persistence.MapKey;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
|
|
||||||
import org.hibernate.AnnotationException;
|
import org.hibernate.AnnotationException;
|
||||||
import org.hibernate.AssertionFailure;
|
import org.hibernate.AssertionFailure;
|
||||||
|
@ -449,7 +450,9 @@ public abstract class CollectionBinder {
|
||||||
tableBinder, mappings
|
tableBinder, mappings
|
||||||
);
|
);
|
||||||
if ( collectionType.isAnnotationPresent( Embeddable.class )
|
if ( collectionType.isAnnotationPresent( Embeddable.class )
|
||||||
|| property.isAnnotationPresent( CollectionOfElements.class ) ) {
|
|| property.isAnnotationPresent( CollectionOfElements.class ) //legacy hibernate
|
||||||
|
|| property.isAnnotationPresent( ElementCollection.class ) //JPA 2
|
||||||
|
) {
|
||||||
// do it right away, otherwise @ManyToon on composite element call addSecondPass
|
// do it right away, otherwise @ManyToon on composite element call addSecondPass
|
||||||
// and raise a ConcurrentModificationException
|
// and raise a ConcurrentModificationException
|
||||||
//sp.doSecondPass( CollectionHelper.EMPTY_MAP );
|
//sp.doSecondPass( CollectionHelper.EMPTY_MAP );
|
||||||
|
@ -483,7 +486,8 @@ public abstract class CollectionBinder {
|
||||||
Fetch fetch = property.getAnnotation( Fetch.class );
|
Fetch fetch = property.getAnnotation( Fetch.class );
|
||||||
OneToMany oneToMany = property.getAnnotation( OneToMany.class );
|
OneToMany oneToMany = property.getAnnotation( OneToMany.class );
|
||||||
ManyToMany manyToMany = property.getAnnotation( ManyToMany.class );
|
ManyToMany manyToMany = property.getAnnotation( ManyToMany.class );
|
||||||
CollectionOfElements elements = property.getAnnotation( CollectionOfElements.class );
|
CollectionOfElements collectionOfElements = property.getAnnotation( CollectionOfElements.class ); //legacy hibernate
|
||||||
|
ElementCollection elementCollection = property.getAnnotation( ElementCollection.class ); //jpa 2
|
||||||
ManyToAny manyToAny = property.getAnnotation( ManyToAny.class );
|
ManyToAny manyToAny = property.getAnnotation( ManyToAny.class );
|
||||||
FetchType fetchType;
|
FetchType fetchType;
|
||||||
if ( oneToMany != null ) {
|
if ( oneToMany != null ) {
|
||||||
|
@ -492,8 +496,11 @@ public abstract class CollectionBinder {
|
||||||
else if ( manyToMany != null ) {
|
else if ( manyToMany != null ) {
|
||||||
fetchType = manyToMany.fetch();
|
fetchType = manyToMany.fetch();
|
||||||
}
|
}
|
||||||
else if ( elements != null ) {
|
else if ( elementCollection != null ) {
|
||||||
fetchType = elements.fetch();
|
fetchType = elementCollection.fetch();
|
||||||
|
}
|
||||||
|
else if ( collectionOfElements != null ) {
|
||||||
|
fetchType = collectionOfElements.fetch();
|
||||||
}
|
}
|
||||||
else if ( manyToAny != null ) {
|
else if ( manyToAny != null ) {
|
||||||
fetchType = FetchType.LAZY;
|
fetchType = FetchType.LAZY;
|
||||||
|
|
|
@ -102,6 +102,7 @@ import javax.persistence.TemporalType;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
import javax.persistence.UniqueConstraint;
|
import javax.persistence.UniqueConstraint;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
|
|
||||||
import org.dom4j.Attribute;
|
import org.dom4j.Attribute;
|
||||||
import org.dom4j.Element;
|
import org.dom4j.Element;
|
||||||
|
@ -563,7 +564,8 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
defaultToJoinTable = defaultToJoinTable &&
|
defaultToJoinTable = defaultToJoinTable &&
|
||||||
( ( annotationClass == ManyToMany.class && StringHelper.isEmpty( ( (ManyToMany) annotation ).mappedBy() ) )
|
( ( annotationClass == ManyToMany.class && StringHelper.isEmpty( ( (ManyToMany) annotation ).mappedBy() ) )
|
||||||
|| ( annotationClass == OneToMany.class && StringHelper.isEmpty( ( (OneToMany) annotation ).mappedBy() ) )
|
|| ( annotationClass == OneToMany.class && StringHelper.isEmpty( ( (OneToMany) annotation ).mappedBy() ) )
|
||||||
|| ( annotationClass == CollectionOfElements.class )
|
|| ( annotationClass == CollectionOfElements.class ) //legacy Hibernate
|
||||||
|
|| ( annotationClass == ElementCollection.class )
|
||||||
);
|
);
|
||||||
final Class<JoinTable> annotationType = JoinTable.class;
|
final Class<JoinTable> annotationType = JoinTable.class;
|
||||||
if ( defaultToJoinTable
|
if ( defaultToJoinTable
|
||||||
|
@ -699,7 +701,41 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
annotation = getJavaAnnotation( Columns.class );
|
annotation = getJavaAnnotation( Columns.class );
|
||||||
addIfNotNull( annotationList, annotation );
|
addIfNotNull( annotationList, annotation );
|
||||||
}
|
}
|
||||||
else if ( isJavaAnnotationPresent( CollectionOfElements.class ) ) {
|
else if ( isJavaAnnotationPresent( ElementCollection.class ) ) { //JPA2
|
||||||
|
annotation = overridesDefaultsInJoinTable( getJavaAnnotation( ElementCollection.class ), defaults );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( JoinColumn.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( JoinColumns.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( PrimaryKeyJoinColumn.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( PrimaryKeyJoinColumns.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( MapKey.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( OrderBy.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( AttributeOverride.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( AttributeOverrides.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( AssociationOverride.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( AssociationOverrides.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( Lob.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( Enumerated.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( Temporal.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( Column.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
annotation = getJavaAnnotation( Columns.class );
|
||||||
|
addIfNotNull( annotationList, annotation );
|
||||||
|
}
|
||||||
|
else if ( isJavaAnnotationPresent( CollectionOfElements.class ) ) { //legacy Hibernate
|
||||||
annotation = overridesDefaultsInJoinTable( getJavaAnnotation( CollectionOfElements.class ), defaults );
|
annotation = overridesDefaultsInJoinTable( getJavaAnnotation( CollectionOfElements.class ), defaults );
|
||||||
addIfNotNull( annotationList, annotation );
|
addIfNotNull( annotationList, annotation );
|
||||||
annotation = getJavaAnnotation( JoinColumn.class );
|
annotation = getJavaAnnotation( JoinColumn.class );
|
||||||
|
|
|
@ -7,6 +7,7 @@ import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
|
|
||||||
import org.hibernate.annotations.CollectionOfElements;
|
import org.hibernate.annotations.CollectionOfElements;
|
||||||
import org.hibernate.annotations.IndexColumn;
|
import org.hibernate.annotations.IndexColumn;
|
||||||
|
@ -40,7 +41,7 @@ public class Contest {
|
||||||
this.results = results;
|
this.results = results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CollectionOfElements
|
@ElementCollection
|
||||||
@IndexColumn(name = "pos", base=1)
|
@IndexColumn(name = "pos", base=1)
|
||||||
public Month[] getHeldIn() {
|
public Month[] getHeldIn() {
|
||||||
return heldIn;
|
return heldIn;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
@ -54,7 +55,8 @@ public class Screen {
|
||||||
this.powerSupply = powerSupply;
|
this.powerSupply = powerSupply;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CollectionOfElements @Valid
|
@ElementCollection
|
||||||
|
@Valid
|
||||||
public Set<DisplayConnector> getConnectors() {
|
public Set<DisplayConnector> getConnectors() {
|
||||||
return connectors;
|
return connectors;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.JoinTable;
|
import javax.persistence.JoinTable;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
|
|
||||||
import org.hibernate.annotations.CollectionOfElements;
|
import org.hibernate.annotations.CollectionOfElements;
|
||||||
import org.hibernate.annotations.IndexColumn;
|
import org.hibernate.annotations.IndexColumn;
|
||||||
|
@ -66,7 +67,7 @@ public class Boy {
|
||||||
this.lastName = lastName;
|
this.lastName = lastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CollectionOfElements
|
@CollectionOfElements //keep hibernate legacy for test purposes
|
||||||
public Set<String> getNickNames() {
|
public Set<String> getNickNames() {
|
||||||
return nickNames;
|
return nickNames;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +76,7 @@ public class Boy {
|
||||||
this.nickNames = nickName;
|
this.nickNames = nickName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CollectionOfElements
|
@ElementCollection
|
||||||
@JoinTable(name = "ScorePerNickName", joinColumns = @JoinColumn(name = "BoyId"))
|
@JoinTable(name = "ScorePerNickName", joinColumns = @JoinColumn(name = "BoyId"))
|
||||||
@Column(name = "score", nullable = false)
|
@Column(name = "score", nullable = false)
|
||||||
public Map<String, Integer> getScorePerNickName() {
|
public Map<String, Integer> getScorePerNickName() {
|
||||||
|
@ -86,7 +87,7 @@ public class Boy {
|
||||||
this.scorePerNickName = scorePerNickName;
|
this.scorePerNickName = scorePerNickName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CollectionOfElements
|
@ElementCollection
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "BoyFavoriteNumbers",
|
name = "BoyFavoriteNumbers",
|
||||||
joinColumns = @JoinColumn(name = "BoyId")
|
joinColumns = @JoinColumn(name = "BoyId")
|
||||||
|
@ -101,7 +102,7 @@ public class Boy {
|
||||||
this.favoriteNumbers = favoriteNumbers;
|
this.favoriteNumbers = favoriteNumbers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CollectionOfElements
|
@CollectionOfElements //TODO migration to ElementCollection "element.serial"??
|
||||||
@AttributeOverride(name = "element.serial", column = @Column(name = "serial_nbr"))
|
@AttributeOverride(name = "element.serial", column = @Column(name = "serial_nbr"))
|
||||||
public Set<Toy> getFavoriteToys() {
|
public Set<Toy> getFavoriteToys() {
|
||||||
return favoriteToys;
|
return favoriteToys;
|
||||||
|
@ -111,7 +112,7 @@ public class Boy {
|
||||||
this.favoriteToys = favoriteToys;
|
this.favoriteToys = favoriteToys;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CollectionOfElements
|
@ElementCollection
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
public Set<Character> getCharacters() {
|
public Set<Character> getCharacters() {
|
||||||
return characters;
|
return characters;
|
||||||
|
@ -121,7 +122,7 @@ public class Boy {
|
||||||
this.characters = characters;
|
this.characters = characters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CollectionOfElements(fetch = FetchType.EAGER)
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
//@Where(clause = "b_likes=false")
|
//@Where(clause = "b_likes=false")
|
||||||
public Set<CountryAttitude> getCountryAttitudes() {
|
public Set<CountryAttitude> getCountryAttitudes() {
|
||||||
return countryAttitudes;
|
return countryAttitudes;
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.test.annotations.collectionelement;
|
package org.hibernate.test.annotations.collectionelement;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
|
|
||||||
import org.hibernate.annotations.CollectionOfElements;
|
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.MapKey;
|
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import org.hibernate.annotations.Filter;
|
import org.hibernate.annotations.Filter;
|
||||||
|
import org.hibernate.annotations.MapKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
|
@ -32,7 +32,7 @@ public class LocalizedString implements Serializable {
|
||||||
private Map<String, String> variations =
|
private Map<String, String> variations =
|
||||||
new HashMap<String, String>( 1 );
|
new HashMap<String, String>( 1 );
|
||||||
|
|
||||||
@CollectionOfElements
|
@ElementCollection
|
||||||
@MapKey( columns = @Column( name = "language_code" ) )
|
@MapKey( columns = @Column( name = "language_code" ) )
|
||||||
@Fetch( FetchMode.JOIN )
|
@Fetch( FetchMode.JOIN )
|
||||||
@Filter( name = "selectedLocale",
|
@Filter( name = "selectedLocale",
|
||||||
|
|
|
@ -4,12 +4,11 @@ package org.hibernate.test.annotations.collectionelement;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
import org.hibernate.annotations.CollectionOfElements;
|
|
||||||
import org.hibernate.annotations.MapKey;
|
import org.hibernate.annotations.MapKey;
|
||||||
import org.hibernate.annotations.Sort;
|
import org.hibernate.annotations.Sort;
|
||||||
import org.hibernate.annotations.SortType;
|
import org.hibernate.annotations.SortType;
|
||||||
|
@ -25,7 +24,7 @@ public class Matrix {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@MapKey(type = @Type(type="integer") )
|
@MapKey(type = @Type(type="integer") )
|
||||||
@CollectionOfElements
|
@ElementCollection
|
||||||
@Sort(type = SortType.NATURAL)
|
@Sort(type = SortType.NATURAL)
|
||||||
@Type(type = "float")
|
@Type(type = "float")
|
||||||
private SortedMap<Integer, Float> values = new TreeMap<Integer, Float>();
|
private SortedMap<Integer, Float> values = new TreeMap<Integer, Float>();
|
||||||
|
|
|
@ -6,6 +6,7 @@ package org.hibernate.test.annotations.collectionelement.deepcollectionelements;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
|
@ -13,7 +14,6 @@ import javax.persistence.Id;
|
||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.CollectionOfElements;
|
|
||||||
import org.hibernate.annotations.IndexColumn;
|
import org.hibernate.annotations.IndexColumn;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@ -23,7 +23,7 @@ public class A {
|
||||||
@GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "aSequence" )
|
@GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "aSequence" )
|
||||||
@SequenceGenerator( name = "aSequence", sequenceName = "seq_A" )
|
@SequenceGenerator( name = "aSequence", sequenceName = "seq_A" )
|
||||||
private int id;
|
private int id;
|
||||||
@CollectionOfElements
|
@ElementCollection
|
||||||
@IndexColumn( name = "ndx" )
|
@IndexColumn( name = "ndx" )
|
||||||
private List<B> listOfB;
|
private List<B> listOfB;
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,8 @@ package org.hibernate.test.annotations.collectionelement.deepcollectionelements;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
import javax.persistence.Transient;
|
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
|
||||||
import org.hibernate.annotations.CollectionOfElements;
|
|
||||||
import org.hibernate.annotations.IndexColumn;
|
import org.hibernate.annotations.IndexColumn;
|
||||||
|
|
||||||
@Embeddable
|
@Embeddable
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.hibernate.annotations.GenericGenerator;
|
||||||
public class Sale {
|
public class Sale {
|
||||||
@Id @GeneratedValue private Integer id;
|
@Id @GeneratedValue private Integer id;
|
||||||
|
|
||||||
@CollectionOfElements
|
@CollectionOfElements //TODO migrate to @ElementCollection, what about @CollectionId
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "contact",
|
name = "contact",
|
||||||
joinColumns = @JoinColumn(name = "n_key_person"))
|
joinColumns = @JoinColumn(name = "n_key_person"))
|
||||||
|
|
|
@ -6,9 +6,10 @@ package org.hibernate.test.annotations.generics;
|
||||||
* @author Edward Costello
|
* @author Edward Costello
|
||||||
* @author Paolo Perrotta
|
* @author Paolo Perrotta
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
import javax.persistence.Embedded;
|
import javax.persistence.Embedded;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
@ -16,8 +17,6 @@ import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
import org.hibernate.annotations.CollectionOfElements;
|
|
||||||
|
|
||||||
public class Classes {
|
public class Classes {
|
||||||
|
|
||||||
@Embeddable
|
@Embeddable
|
||||||
|
@ -41,7 +40,7 @@ public class Classes {
|
||||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||||
Long id;
|
Long id;
|
||||||
|
|
||||||
@CollectionOfElements
|
@ElementCollection
|
||||||
Set<Edition<String>> editions = new HashSet<Edition<String>>();
|
Set<Edition<String>> editions = new HashSet<Edition<String>>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class Atmosphere {
|
||||||
@JoinTable(name = "Gas_per_key")
|
@JoinTable(name = "Gas_per_key")
|
||||||
public Map<GasKey, Gas> gasesPerKey = new HashMap<GasKey, Gas>();
|
public Map<GasKey, Gas> gasesPerKey = new HashMap<GasKey, Gas>();
|
||||||
|
|
||||||
@CollectionOfElements
|
@CollectionOfElements //TODO migrate to @ElementCollection ; @MapKeyManyToMany ??
|
||||||
@Column(name="composition_rate")
|
@Column(name="composition_rate")
|
||||||
@MapKeyManyToMany(joinColumns = @JoinColumn(name="gas_id"))
|
@MapKeyManyToMany(joinColumns = @JoinColumn(name="gas_id"))
|
||||||
@JoinTable(name = "Composition", joinColumns = @JoinColumn(name = "atmosphere_id"))
|
@JoinTable(name = "Composition", joinColumns = @JoinColumn(name = "atmosphere_id"))
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.test.annotations.target;
|
package org.hibernate.test.annotations.target;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
|
|
||||||
import org.hibernate.annotations.MapKey;
|
import org.hibernate.annotations.MapKey;
|
||||||
import org.hibernate.annotations.CollectionOfElements;
|
|
||||||
import org.hibernate.annotations.MapKeyManyToMany;
|
import org.hibernate.annotations.MapKeyManyToMany;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,7 @@ public class Brand {
|
||||||
@MapKey(targetElement = SizeImpl.class)
|
@MapKey(targetElement = SizeImpl.class)
|
||||||
private Map<Size, Luggage> luggagesBySize = new HashMap<Size, Luggage>();
|
private Map<Size, Luggage> luggagesBySize = new HashMap<Size, Luggage>();
|
||||||
|
|
||||||
@CollectionOfElements(targetElement = SizeImpl.class)
|
@ElementCollection(targetClass = SizeImpl.class)
|
||||||
@MapKeyManyToMany(targetEntity = LuggageImpl.class)
|
@MapKeyManyToMany(targetEntity = LuggageImpl.class)
|
||||||
private Map<Luggage, Size> sizePerLuggage = new HashMap<Luggage, Size>();
|
private Map<Luggage, Size> sizePerLuggage = new HashMap<Luggage, Size>();
|
||||||
|
|
||||||
|
|
|
@ -56,10 +56,9 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.persistence</groupId>
|
<groupId>org.hibernate.java-persistence</groupId>
|
||||||
<artifactId>persistence-api</artifactId>
|
<artifactId>jpa-api</artifactId>
|
||||||
<version>1.0</version>
|
<version>2.0.Beta1</version>
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// $Id:$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* JBoss, the OpenSource EJB server Distributable under LGPL license. See terms of license at
|
* JBoss, the OpenSource EJB server Distributable under LGPL license. See terms of license at
|
||||||
* gnu.org.
|
* gnu.org.
|
||||||
|
@ -10,6 +10,7 @@ import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.EntityNotFoundException;
|
import javax.persistence.EntityNotFoundException;
|
||||||
import javax.persistence.EntityTransaction;
|
import javax.persistence.EntityTransaction;
|
||||||
|
@ -22,6 +23,10 @@ import javax.persistence.PersistenceContextType;
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
import javax.persistence.TransactionRequiredException;
|
import javax.persistence.TransactionRequiredException;
|
||||||
|
import javax.persistence.EntityManagerFactory;
|
||||||
|
import javax.persistence.metamodel.Metamodel;
|
||||||
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
import javax.persistence.criteria.QueryBuilder;
|
||||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||||
import javax.transaction.Status;
|
import javax.transaction.Status;
|
||||||
import javax.transaction.Synchronization;
|
import javax.transaction.Synchronization;
|
||||||
|
@ -98,6 +103,10 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Query createQuery(CriteriaQuery criteriaQuery) {
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
public Query createNamedQuery(String name) {
|
public Query createNamedQuery(String name) {
|
||||||
//adjustFlushMode();
|
//adjustFlushMode();
|
||||||
org.hibernate.Query namedQuery;
|
org.hibernate.Query namedQuery;
|
||||||
|
@ -204,6 +213,21 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T> T find(Class<T> tClass, Object o, Map<String, Object> stringObjectMap) {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T find(Class<T> tClass, Object o, LockModeType lockModeType) {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T find(Class<T> tClass, Object o, LockModeType lockModeType, Map<String, Object> stringObjectMap) {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
private void checkTransactionNeeded() {
|
private void checkTransactionNeeded() {
|
||||||
if ( persistenceContextType == PersistenceContextType.TRANSACTION && ! isTransactionInProgress() ) {
|
if ( persistenceContextType == PersistenceContextType.TRANSACTION && ! isTransactionInProgress() ) {
|
||||||
//no need to mark as rollback, no tx in progress
|
//no need to mark as rollback, no tx in progress
|
||||||
|
@ -277,6 +301,21 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void refresh(Object o, Map<String, Object> stringObjectMap) {
|
||||||
|
//FIXME
|
||||||
|
//To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh(Object o, LockModeType lockModeType) {
|
||||||
|
//FIXME
|
||||||
|
//To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh(Object o, LockModeType lockModeType, Map<String, Object> stringObjectMap) {
|
||||||
|
//FIXME
|
||||||
|
//To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
public boolean contains(Object entity) {
|
public boolean contains(Object entity) {
|
||||||
try {
|
try {
|
||||||
if ( entity != null
|
if ( entity != null
|
||||||
|
@ -295,6 +334,26 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LockModeType getLockMode(Object o) {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProperty(String s, Object o) {
|
||||||
|
//FIXME
|
||||||
|
//To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getProperties() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getSupportedProperties() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
public void flush() {
|
public void flush() {
|
||||||
try {
|
try {
|
||||||
if ( ! isTransactionInProgress() ) {
|
if ( ! isTransactionInProgress() ) {
|
||||||
|
@ -326,6 +385,21 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EntityManagerFactory getEntityManagerFactory() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueryBuilder getQueryBuilder() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public Metamodel getMetamodel() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
public void setFlushMode(FlushModeType flushModeType) {
|
public void setFlushMode(FlushModeType flushModeType) {
|
||||||
this.flushModeType = flushModeType;
|
this.flushModeType = flushModeType;
|
||||||
if ( flushModeType == FlushModeType.AUTO ) {
|
if ( flushModeType == FlushModeType.AUTO ) {
|
||||||
|
@ -349,6 +423,10 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void detach(Object entity) {
|
||||||
|
getSession().evict( entity );
|
||||||
|
}
|
||||||
|
|
||||||
public FlushModeType getFlushMode() {
|
public FlushModeType getFlushMode() {
|
||||||
FlushMode mode = getSession().getFlushMode();
|
FlushMode mode = getSession().getFlushMode();
|
||||||
if ( mode == FlushMode.AUTO ) {
|
if ( mode == FlushMode.AUTO ) {
|
||||||
|
@ -387,6 +465,11 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void lock(Object o, LockModeType lockModeType, Map<String, Object> stringObjectMap) {
|
||||||
|
//FIXME
|
||||||
|
//To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
private LockMode getLockMode(LockModeType lockMode) {
|
private LockMode getLockMode(LockModeType lockMode) {
|
||||||
switch ( lockMode ) {
|
switch ( lockMode ) {
|
||||||
case READ:
|
case READ:
|
||||||
|
@ -431,6 +514,13 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
joinTransaction( false );
|
joinTransaction( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T> T unwrap(Class<T> clazz) {
|
||||||
|
if (clazz.equals( Session.class ) ) return (T) getSession();
|
||||||
|
if (clazz.equals( SessionImplementor.class ) ) return (T) getSession();
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
private void joinTransaction(boolean ignoreNotJoining) {
|
private void joinTransaction(boolean ignoreNotJoining) {
|
||||||
//set the joined status
|
//set the joined status
|
||||||
getSession().isOpen(); //for sync
|
getSession().isOpen(); //for sync
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
package org.hibernate.ejb;
|
package org.hibernate.ejb;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContextType;
|
import javax.persistence.PersistenceContextType;
|
||||||
|
import javax.persistence.Cache;
|
||||||
|
import javax.persistence.metamodel.Metamodel;
|
||||||
|
import javax.persistence.criteria.QueryBuilder;
|
||||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||||
|
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
|
@ -42,10 +46,35 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QueryBuilder getQueryBuilder() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public Metamodel getMetamodel() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getProperties() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getSupportedProperties() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cache getCache() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isOpen() {
|
public boolean isOpen() {
|
||||||
return ! sessionFactory.isClosed();
|
return ! sessionFactory.isClosed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,23 @@
|
||||||
package org.hibernate.ejb;
|
package org.hibernate.ejb;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Member;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.lang.reflect.AccessibleObject;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import javax.persistence.EntityManagerFactory;
|
import javax.persistence.EntityManagerFactory;
|
||||||
|
import javax.persistence.PersistenceException;
|
||||||
import javax.persistence.spi.PersistenceUnitInfo;
|
import javax.persistence.spi.PersistenceUnitInfo;
|
||||||
|
import javax.persistence.spi.LoadState;
|
||||||
|
|
||||||
|
import org.hibernate.Hibernate;
|
||||||
|
import org.hibernate.intercept.FieldInterceptionHelper;
|
||||||
|
import org.hibernate.intercept.FieldInterceptor;
|
||||||
|
import org.hibernate.collection.PersistentCollection;
|
||||||
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
|
import org.hibernate.proxy.LazyInitializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hibernate EJB3 persistence provider implementation
|
* Hibernate EJB3 persistence provider implementation
|
||||||
|
@ -132,6 +147,135 @@ public class HibernatePersistence implements javax.persistence.spi.PersistencePr
|
||||||
return configured != null ? configured.buildEntityManagerFactory() : null;
|
return configured != null ? configured.buildEntityManagerFactory() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LoadState isLoadedWithoutReference(Object proxy, String property) {
|
||||||
|
Object entity;
|
||||||
|
boolean sureFromUs = false;
|
||||||
|
if ( proxy instanceof HibernateProxy ) {
|
||||||
|
LazyInitializer li = ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer();
|
||||||
|
if ( li.isUninitialized() ) {
|
||||||
|
return LoadState.NOT_LOADED;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entity = li.getImplementation();
|
||||||
|
}
|
||||||
|
sureFromUs = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entity = proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
//we are instrumenting but we can't assume we are the only ones
|
||||||
|
if ( FieldInterceptionHelper.isInstrumented( entity ) ) {
|
||||||
|
FieldInterceptor interceptor = FieldInterceptionHelper.extractFieldInterceptor( entity );
|
||||||
|
final boolean isInitialized = interceptor == null || interceptor.isInitialized( property );
|
||||||
|
LoadState state;
|
||||||
|
if (isInitialized && interceptor != null) {
|
||||||
|
state = LoadState.LOADED;
|
||||||
|
}
|
||||||
|
else if ( interceptor != null && (! isInitialized)) {
|
||||||
|
state = LoadState.NOT_LOADED;
|
||||||
|
}
|
||||||
|
else if ( sureFromUs ) { //interceptor == null
|
||||||
|
state = LoadState.LOADED;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
state = LoadState.UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//can't do sureFromUs ? LoadState.LOADED : LoadState.UNKNOWN;
|
||||||
|
//is that an association?
|
||||||
|
return LoadState.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoadState isLoadedWithReference(Object proxy, String property) {
|
||||||
|
//for sure we don't instrument and for sure it's not a lazy proxy
|
||||||
|
Object object = get(proxy, property);
|
||||||
|
return isLoaded( object );
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object get(Object proxy, String property) {
|
||||||
|
final Class<?> clazz = proxy.getClass();
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
final Field field = clazz.getField( property );
|
||||||
|
setAccessibility( field );
|
||||||
|
return field.get( proxy );
|
||||||
|
}
|
||||||
|
catch ( NoSuchFieldException e ) {
|
||||||
|
final Method method = getMethod( clazz, property );
|
||||||
|
if (method != null) {
|
||||||
|
setAccessibility( method );
|
||||||
|
return method.invoke( proxy );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new PersistenceException( "Unable to find field or method: "
|
||||||
|
+ clazz + "#"
|
||||||
|
+ property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( IllegalAccessException e ) {
|
||||||
|
throw new PersistenceException( "Unable to access field or method: "
|
||||||
|
+ clazz + "#"
|
||||||
|
+ property, e);
|
||||||
|
}
|
||||||
|
catch ( InvocationTargetException e ) {
|
||||||
|
throw new PersistenceException( "Unable to access field or method: "
|
||||||
|
+ clazz + "#"
|
||||||
|
+ property, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the method with the specified name or <code>null</code> if it does not exist.
|
||||||
|
*
|
||||||
|
* @param clazz The class to check.
|
||||||
|
* @param methodName The method name.
|
||||||
|
*
|
||||||
|
* @return Returns the method with the specified name or <code>null</code> if it does not exist.
|
||||||
|
*/
|
||||||
|
public static Method getMethod(Class<?> clazz, String methodName) {
|
||||||
|
try {
|
||||||
|
char string[] = methodName.toCharArray();
|
||||||
|
string[0] = Character.toUpperCase( string[0] );
|
||||||
|
methodName = new String( string );
|
||||||
|
try {
|
||||||
|
return clazz.getMethod( "get" + methodName );
|
||||||
|
}
|
||||||
|
catch ( NoSuchMethodException e ) {
|
||||||
|
return clazz.getMethod( "is" + methodName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( NoSuchMethodException e ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAccessibility(Member member) {
|
||||||
|
if ( !Modifier.isPublic( member.getModifiers() ) ) {
|
||||||
|
//Sun's ease of use, sigh...
|
||||||
|
( ( AccessibleObject ) member ).setAccessible( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoadState isLoaded(Object o) {
|
||||||
|
if ( o instanceof HibernateProxy ) {
|
||||||
|
final boolean isInitialized = !( ( HibernateProxy ) o ).getHibernateLazyInitializer().isUninitialized();
|
||||||
|
return isInitialized ? LoadState.LOADED : LoadState.NOT_LOADED;
|
||||||
|
}
|
||||||
|
else if ( o instanceof PersistentCollection ) {
|
||||||
|
final boolean isInitialized = ( ( PersistentCollection ) o ).wasInitialized();
|
||||||
|
return isInitialized ? LoadState.LOADED : LoadState.NOT_LOADED;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return LoadState.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a factory from a canonical version
|
* create a factory from a canonical version
|
||||||
* @deprecated
|
* @deprecated
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.Map;
|
||||||
import javax.persistence.FlushModeType;
|
import javax.persistence.FlushModeType;
|
||||||
import javax.persistence.NoResultException;
|
import javax.persistence.NoResultException;
|
||||||
import javax.persistence.NonUniqueResultException;
|
import javax.persistence.NonUniqueResultException;
|
||||||
|
@ -14,6 +15,7 @@ import javax.persistence.Query;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
import static javax.persistence.TemporalType.*;
|
import static javax.persistence.TemporalType.*;
|
||||||
import javax.persistence.TransactionRequiredException;
|
import javax.persistence.TransactionRequiredException;
|
||||||
|
import javax.persistence.LockModeType;
|
||||||
|
|
||||||
import org.hibernate.FlushMode;
|
import org.hibernate.FlushMode;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
@ -32,6 +34,7 @@ public class QueryImpl implements Query, HibernateQuery {
|
||||||
private HibernateEntityManagerImplementor em;
|
private HibernateEntityManagerImplementor em;
|
||||||
private Boolean isPositional = null;
|
private Boolean isPositional = null;
|
||||||
private int maxResults = -1;
|
private int maxResults = -1;
|
||||||
|
private int firstResult;
|
||||||
|
|
||||||
public QueryImpl(org.hibernate.Query query, AbstractEntityManagerImpl em) {
|
public QueryImpl(org.hibernate.Query query, AbstractEntityManagerImpl em) {
|
||||||
this.query = query;
|
this.query = query;
|
||||||
|
@ -143,6 +146,10 @@ public class QueryImpl implements Query, HibernateQuery {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxResults() {
|
||||||
|
return maxResults == -1 ? Integer.MAX_VALUE : maxResults; //stupid spec MAX_VALUE??
|
||||||
|
}
|
||||||
|
|
||||||
public Query setFirstResult(int firstResult) {
|
public Query setFirstResult(int firstResult) {
|
||||||
if ( firstResult < 0 ) {
|
if ( firstResult < 0 ) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
@ -152,9 +159,14 @@ public class QueryImpl implements Query, HibernateQuery {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
query.setFirstResult( firstResult );
|
query.setFirstResult( firstResult );
|
||||||
|
this.firstResult = firstResult;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFirstResult() {
|
||||||
|
return firstResult;
|
||||||
|
}
|
||||||
|
|
||||||
public Query setHint(String hintName, Object value) {
|
public Query setHint(String hintName, Object value) {
|
||||||
try {
|
try {
|
||||||
if ( "org.hibernate.timeout".equals( hintName ) ) {
|
if ( "org.hibernate.timeout".equals( hintName ) ) {
|
||||||
|
@ -192,6 +204,16 @@ public class QueryImpl implements Query, HibernateQuery {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getHints() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getSupportedHints() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
public Query setParameter(String name, Object value) {
|
public Query setParameter(String name, Object value) {
|
||||||
try {
|
try {
|
||||||
if ( value instanceof Collection ) {
|
if ( value instanceof Collection ) {
|
||||||
|
@ -351,6 +373,16 @@ public class QueryImpl implements Query, HibernateQuery {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getNamedParameters() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getPositionalParameters() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
public Query setFlushMode(FlushModeType flushMode) {
|
public Query setFlushMode(FlushModeType flushMode) {
|
||||||
if ( flushMode == FlushModeType.AUTO ) {
|
if ( flushMode == FlushModeType.AUTO ) {
|
||||||
query.setFlushMode( FlushMode.AUTO );
|
query.setFlushMode( FlushMode.AUTO );
|
||||||
|
@ -360,4 +392,24 @@ public class QueryImpl implements Query, HibernateQuery {
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FlushModeType getFlushMode() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public Query setLockMode(LockModeType lockModeType) {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public LockModeType getLockMode() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T unwrap(Class<T> tClass) {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ public class PackagedEntityManagerTest extends TestCase {
|
||||||
public void testListeners() throws Exception {
|
public void testListeners() throws Exception {
|
||||||
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "manager1", new HashMap() );
|
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "manager1", new HashMap() );
|
||||||
EntityManager em = emf.createEntityManager();
|
EntityManager em = emf.createEntityManager();
|
||||||
EventListeners eventListeners = ( (SessionImplementor) em.getDelegate() ).getListeners();
|
EventListeners eventListeners = em.unwrap(SessionImplementor.class).getListeners();
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Explicit pre-insert event through hibernate.ejb.event.pre-insert does not work",
|
"Explicit pre-insert event through hibernate.ejb.event.pre-insert does not work",
|
||||||
eventListeners.getPreInsertEventListeners().length,
|
eventListeners.getPreInsertEventListeners().length,
|
||||||
|
|
|
@ -8,6 +8,8 @@ import java.util.Properties;
|
||||||
import javax.persistence.spi.ClassTransformer;
|
import javax.persistence.spi.ClassTransformer;
|
||||||
import javax.persistence.spi.PersistenceUnitInfo;
|
import javax.persistence.spi.PersistenceUnitInfo;
|
||||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||||
|
import javax.persistence.Caching;
|
||||||
|
import javax.persistence.ValidationMode;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
@ -71,6 +73,10 @@ public class PersistenceUnitInfoImpl implements PersistenceUnitInfo {
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String PersistenceXMLSchemaVersion() {
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
public ClassLoader getClassLoader() {
|
public ClassLoader getClassLoader() {
|
||||||
return Thread.currentThread().getContextClassLoader();
|
return Thread.currentThread().getContextClassLoader();
|
||||||
}
|
}
|
||||||
|
@ -87,6 +93,16 @@ public class PersistenceUnitInfoImpl implements PersistenceUnitInfo {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Caching getCaching() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValidationMode getValidationMode() {
|
||||||
|
//FIXME
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
public void addTransformer(ClassTransformer transformer) {
|
public void addTransformer(ClassTransformer transformer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class CascadePersistTest extends TestCase {
|
||||||
c2.setB2( anotherB2 );
|
c2.setB2( anotherB2 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Statistics statistics = ( (Session) em.getDelegate() ).getSessionFactory().getStatistics();
|
Statistics statistics = em.unwrap(Session.class).getSessionFactory().getStatistics();
|
||||||
statistics.setStatisticsEnabled( true );
|
statistics.setStatisticsEnabled( true );
|
||||||
statistics.clear();
|
statistics.clear();
|
||||||
em.persist( c2 );
|
em.persist( c2 );
|
||||||
|
|
|
@ -271,7 +271,7 @@ public class FlushAndTransactionTest extends TestCase {
|
||||||
em.flush();
|
em.flush();
|
||||||
em.clear();
|
em.clear();
|
||||||
book.setName( "kitty kid2"); //non updated version
|
book.setName( "kitty kid2"); //non updated version
|
||||||
( (Session) em.getDelegate() ).update( book );
|
em.unwrap( Session.class ).update( book );
|
||||||
try {
|
try {
|
||||||
em.getTransaction().commit();
|
em.getTransaction().commit();
|
||||||
fail( "Commit should be rollbacked" );
|
fail( "Commit should be rollbacked" );
|
||||||
|
|
|
@ -70,8 +70,9 @@
|
||||||
<artifactId>hibernate-core</artifactId>
|
<artifactId>hibernate-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.persistence</groupId>
|
<groupId>org.hibernate.java-persistence</groupId>
|
||||||
<artifactId>persistence-api</artifactId>
|
<artifactId>jpa-api</artifactId>
|
||||||
|
<version>2.0.Beta1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
|
|
|
@ -24,14 +24,14 @@
|
||||||
package org.hibernate.envers;
|
package org.hibernate.envers;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceException;
|
||||||
|
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.envers.event.AuditEventListener;
|
import org.hibernate.envers.event.AuditEventListener;
|
||||||
import org.hibernate.envers.exception.AuditException;
|
import org.hibernate.envers.exception.AuditException;
|
||||||
import org.hibernate.envers.reader.AuditReaderImpl;
|
import org.hibernate.envers.reader.AuditReaderImpl;
|
||||||
import static org.hibernate.envers.tools.ArraysTools.arrayIncludesInstanceOf;
|
import static org.hibernate.envers.tools.ArraysTools.arrayIncludesInstanceOf;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
|
||||||
import org.hibernate.engine.SessionImplementor;
|
|
||||||
import org.hibernate.event.EventListeners;
|
import org.hibernate.event.EventListeners;
|
||||||
import org.hibernate.event.PostInsertEventListener;
|
import org.hibernate.event.PostInsertEventListener;
|
||||||
|
|
||||||
|
@ -81,17 +81,11 @@ public class AuditReaderFactory {
|
||||||
* listeners aren't installed.
|
* listeners aren't installed.
|
||||||
*/
|
*/
|
||||||
public static AuditReader get(EntityManager entityManager) throws AuditException {
|
public static AuditReader get(EntityManager entityManager) throws AuditException {
|
||||||
if (entityManager.getDelegate() instanceof Session) {
|
try {
|
||||||
return get((Session) entityManager.getDelegate());
|
return get( entityManager.unwrap(Session.class) );
|
||||||
}
|
}
|
||||||
|
catch ( PersistenceException e ) {
|
||||||
if (entityManager.getDelegate() instanceof EntityManager) {
|
|
||||||
entityManager = (EntityManager) entityManager.getDelegate();
|
|
||||||
if (entityManager.getDelegate() instanceof Session) {
|
|
||||||
return get((Session) entityManager.getDelegate());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new AuditException("Hibernate EntityManager not present!");
|
throw new AuditException("Hibernate EntityManager not present!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
package org.jboss.envers;
|
package org.jboss.envers;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceException;
|
||||||
|
|
||||||
import org.hibernate.envers.event.AuditEventListener;
|
import org.hibernate.envers.event.AuditEventListener;
|
||||||
import org.hibernate.envers.reader.AuditReaderImpl;
|
import org.hibernate.envers.reader.AuditReaderImpl;
|
||||||
|
@ -81,16 +82,11 @@ public class VersionsReaderFactory {
|
||||||
* listeners aren't installed.
|
* listeners aren't installed.
|
||||||
*/
|
*/
|
||||||
public static VersionsReader get(EntityManager entityManager) throws VersionsException {
|
public static VersionsReader get(EntityManager entityManager) throws VersionsException {
|
||||||
if (entityManager.getDelegate() instanceof Session) {
|
try {
|
||||||
return get((Session) entityManager.getDelegate());
|
return get( entityManager.unwrap(Session.class) );
|
||||||
}
|
}
|
||||||
|
catch ( PersistenceException e ) {
|
||||||
if (entityManager.getDelegate() instanceof EntityManager) {
|
|
||||||
if (entityManager.getDelegate() instanceof Session) {
|
|
||||||
return get((Session) entityManager.getDelegate());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new VersionsException("Hibernate EntityManager not present!");
|
throw new VersionsException("Hibernate EntityManager not present!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -25,6 +25,7 @@ package org.hibernate.envers.test.integration.flush;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceException;
|
||||||
|
|
||||||
import org.hibernate.envers.test.AbstractEntityTest;
|
import org.hibernate.envers.test.AbstractEntityTest;
|
||||||
import org.hibernate.envers.test.entities.StrTestEntity;
|
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||||
|
@ -45,18 +46,12 @@ public abstract class AbstractFlushTest extends AbstractEntityTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Session getSession(EntityManager em) {
|
private static Session getSession(EntityManager em) {
|
||||||
Object delegate = em.getDelegate();
|
try {
|
||||||
if (delegate instanceof Session) {
|
return em.unwrap( Session.class );
|
||||||
return (Session) delegate;
|
|
||||||
} else if (delegate instanceof EntityManager) {
|
|
||||||
Object delegate2 = ((EntityManager) delegate).getDelegate();
|
|
||||||
|
|
||||||
if (delegate2 instanceof Session) {
|
|
||||||
return (Session) delegate2;
|
|
||||||
}
|
}
|
||||||
|
catch ( PersistenceException e ) {
|
||||||
|
throw new RuntimeException("Invalid entity manager", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new RuntimeException("Invalid entity manager");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass(dependsOnMethods = "init")
|
@BeforeClass(dependsOnMethods = "init")
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class HsqlTest {
|
||||||
|
|
||||||
entityManager.getTransaction().begin();
|
entityManager.getTransaction().begin();
|
||||||
|
|
||||||
Session sesion = (Session) entityManager.getDelegate();
|
Session sesion = entityManager.unwrap(Session.class);
|
||||||
System.out.println(sesion.createQuery(
|
System.out.println(sesion.createQuery(
|
||||||
"select e from org.hibernate.envers.demo.Person_versions e " +
|
"select e from org.hibernate.envers.demo.Person_versions e " +
|
||||||
"where " +
|
"where " +
|
||||||
|
|
Loading…
Reference in New Issue