Skip to content

Commit

Permalink
HHH-10664 - Fix SortedSet issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dreab8 authored and sebersole committed May 6, 2016
1 parent b4b158a commit 5c5de94
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
Expand Up @@ -17,6 +17,7 @@
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.persister.collection.BasicCollectionPersister;

/**
Expand All @@ -41,7 +42,7 @@ public PersistentSortedMap() {
*
* @param session The session
*/
public PersistentSortedMap(SessionImplementor session) {
public PersistentSortedMap(SharedSessionContractImplementor session) {
super( session );
}

Expand All @@ -51,7 +52,7 @@ public PersistentSortedMap(SessionImplementor session) {
* @param session The session
* @param map The underlying map data
*/
public PersistentSortedMap(SessionImplementor session, SortedMap map) {
public PersistentSortedMap(SharedSessionContractImplementor session, SortedMap map) {
super( session, map );
comparator = map.comparator();
}
Expand Down
Expand Up @@ -14,6 +14,7 @@
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.persister.collection.BasicCollectionPersister;

/**
Expand All @@ -38,7 +39,7 @@ public PersistentSortedSet() {
*
* @param session The session
*/
public PersistentSortedSet(SessionImplementor session) {
public PersistentSortedSet(SharedSessionContractImplementor session) {
super( session );
}

Expand All @@ -48,7 +49,7 @@ public PersistentSortedSet(SessionImplementor session) {
* @param session The session
* @param set The underlying set data
*/
public PersistentSortedSet(SessionImplementor session, SortedSet set) {
public PersistentSortedSet(SharedSessionContractImplementor session, SortedSet set) {
super( session, set );
comparator = set.comparator();
}
Expand Down
Expand Up @@ -9,7 +9,7 @@
import java.lang.reflect.Method;

import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.tuple.component.ComponentMetamodel;

/**
Expand All @@ -28,7 +28,8 @@ public boolean isMethodOf(Method method) {
return componentTuplizer.isMethodOf( method );
}

public Object instantiate(Object parent, SessionImplementor session) throws HibernateException {
@Override
public Object instantiate(Object parent, SharedSessionContractImplementor session) throws HibernateException {
final boolean useParent = parent != null &&
//TODO: Yuck! This is not quite good enough, it's a quick
//hack around the problem of having a to-one association
Expand Down
Expand Up @@ -12,7 +12,7 @@

import org.hibernate.collection.internal.PersistentSortedMap;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.persister.collection.CollectionPersister;


Expand All @@ -25,7 +25,8 @@ public SortedMapType(TypeFactory.TypeScope typeScope, String role, String proper
this.comparator = comparator;
}

public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key) {
@Override
public PersistentCollection instantiate(SharedSessionContractImplementor session, CollectionPersister persister, Serializable key) {
PersistentSortedMap map = new PersistentSortedMap(session);
map.setComparator(comparator);
return map;
Expand All @@ -39,8 +40,9 @@ public Class getReturnedClass() {
public Object instantiate(int anticipatedSize) {
return new TreeMap(comparator);
}

public PersistentCollection wrap(SessionImplementor session, Object collection) {

@Override
public PersistentCollection wrap(SharedSessionContractImplementor session, Object collection) {
return new PersistentSortedMap( session, (java.util.SortedMap) collection );
}
}
Expand Up @@ -12,7 +12,7 @@

import org.hibernate.collection.internal.PersistentSortedSet;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.persister.collection.CollectionPersister;

public class SortedSetType extends SetType {
Expand All @@ -23,7 +23,8 @@ public SortedSetType(TypeFactory.TypeScope typeScope, String role, String proper
this.comparator = comparator;
}

public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key) {
@Override
public PersistentCollection instantiate(SharedSessionContractImplementor session, CollectionPersister persister, Serializable key) {
PersistentSortedSet set = new PersistentSortedSet(session);
set.setComparator(comparator);
return set;
Expand All @@ -37,8 +38,9 @@ public Class getReturnedClass() {
public Object instantiate(int anticipatedSize) {
return new TreeSet(comparator);
}

public PersistentCollection wrap(SessionImplementor session, Object collection) {

@Override
public PersistentCollection wrap(SharedSessionContractImplementor session, Object collection) {
return new PersistentSortedSet( session, (java.util.SortedSet) collection );
}
}
Expand Up @@ -15,8 +15,8 @@
import org.hibernate.MappingException;
import org.hibernate.engine.internal.ForeignKeys;
import org.hibernate.engine.spi.Mapping;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.spi.SharedSessionContractImplementor;

/**
* A one-to-one association that maps to specific formula(s)
Expand Down Expand Up @@ -86,16 +86,17 @@ public Size[] defaultSizes(Mapping mapping) throws MappingException {
public boolean useLHSPrimaryKey() {
return false;
}

public Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner)

@Override
public Object hydrate(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
throws HibernateException, SQLException {
return super.getIdentifierOrUniqueKeyType( session.getFactory() )
.nullSafeGet(rs, names, session, owner);
}

// TODO: copy/paste from ManyToOneType

public Serializable disassemble(Object value, SessionImplementor session, Object owner)
@Override
public Serializable disassemble(Object value, SharedSessionContractImplementor session, Object owner)
throws HibernateException {

if (value==null) {
Expand All @@ -115,7 +116,8 @@ public Serializable disassemble(Object value, SessionImplementor session, Object
}
}

public Object assemble(Serializable oid, SessionImplementor session, Object owner)
@Override
public Object assemble(Serializable oid, SharedSessionContractImplementor session, Object owner)
throws HibernateException {
//TODO: currently broken for unique-key references (does not detect
// change to unique key property of the associated object)
Expand Down

0 comments on commit 5c5de94

Please sign in to comment.