HHH-6525 : Integrate Set-style plural attributes into persisters

This commit is contained in:
Gail Badner 2012-02-27 12:36:38 -08:00
parent c4d48cfcb6
commit bd0fcdd2f7
2 changed files with 9 additions and 6 deletions

View File

@ -761,7 +761,7 @@ public AbstractCollectionPersister(
else {
org.hibernate.metamodel.spi.relational.Column col = (org.hibernate.metamodel.spi.relational.Column) value;
elementColumnNames[j] = col.getColumnName().encloseInQuotesIfQuoted( dialect );
elementColumnWriters[j] = col.getWriteFragment();
elementColumnWriters[j] = col.getWriteFragment() == null ? "?" : col.getWriteFragment();
elementColumnReaders[j] = col.getReadFragment() == null ?
col.getColumnName().encloseInQuotesIfQuoted( factory.getDialect() ) :
col.getReadFragment();

View File

@ -33,9 +33,10 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
@ -53,22 +54,24 @@ public void configure(Configuration cfg) {
}
@Test
@FailureExpected( jiraKey = "HHH-6525")
public void testLoad() throws HibernateException, SQLException {
Session s = openSession();
Transaction t = s.beginTransaction();
User u = new User( );
u.setUserName( "username" );
u.getSessionAttributeNames().add( "name" );
u.getSessionAttributeNames().add( "anothername" );
s.save( u );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
u = (User) s.get( User.class, "name" );
u.getSessionAttributeNames().add( "bar" );
u = (User) s.get( User.class, "username" );
assertFalse( Hibernate.isInitialized( u.getSessionAttributeNames() ) );
assertEquals( 2, u.getSessionAttributeNames().size() );
assertTrue( Hibernate.isInitialized( u.getSessionAttributeNames() ) );
assertTrue( u.getSessionAttributeNames().contains( "name" ) );
assertTrue( u.getSessionAttributeNames().contains( "anothername" ) );
s.delete( u );
t.commit();
s.close();