Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so dont bother with any of their useless mail servers here and just use oauth login instead. Thank the nice Russians for causing that. :)

Paste

Pasted as Java by kossmoboleat ( 16 years ago )
package org.hibernate.test.annotations.onetoone.referencedcolumnname;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;

public class OneToOne_referencedColumnName_Test extends org.hibernate.test.annotations.TestCase {
 
 @Test
 public void testNothing(){
  
 }
 
 @Test
 public void testOneToOneWithReferencedColumnName(){
  Session s;
  Transaction tx;
  s = openSession();
  tx = s.beginTransaction();
  
  HI hi = new HI();
  hi.setId("1");
  s.save(hi);
  
  H h = new H();
  h.setId("2");
  h.setObjId("h2");
  s.save(h);
  hi.setH(h);

  tx.commit();
  s = openSession();
  tx = s.beginTransaction();
  
  h = (H) s.get(H.class, h.getId());
  assertNotNull(h);
  
  assertNotNull(h.getHiObject());
  assertEquals(h.getHiObject().getId(),hi.getId());
  assertEquals(h.getId(),h.getHiObject().getH().getId());
  
  tx.commit();
  s.clear();
  tx = s.beginTransaction();
  
  hi = (HI) s.get(HI.class, hi.getId());
  assertNotNull(hi);
  
  assertNotNull(hi.getH());
  assertEquals(hi.getId(),hi.getId());
  assertEquals(hi.getId(),hi.getH().getHiObject().getId());
  
  s.delete(hi.getH());
  s.delete(hi);
  tx.commit();
  s.close();
 }
 
 @Override
 protected Class<?>[] getAnnotatedClasses() {
  return new Class<?>[]{H.class,HI.class};
 }

 
 
}

 

Revise this Paste

Your Name: Code Language: