-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: JPwH Errata: Page 722: about Serializable interface ?
PostPosted: Sun Sep 02, 2007 6:03 am 
Newbie

Joined: Wed Aug 02, 2006 9:40 pm
Posts: 13
Location: China
second paragraph:

Because Command instances are sent across the wire, you need to implement Serializable (this marker should be in the concrete class, not the superclasses or interfaces).

Serializable can be in the superclasses or interfaces.

for example:

in the superclasses:
Code:
public class SerializableParent implements Serializable
{
   public SerializableParent()
   {
      super();
      System.out.println("Serializable Parent...");
   }
}

// Only extends SuperClass
public class SerializableChild extends SerializableParent
{
   public SerializableChild()
   {
      super();
      System.out.println("Serializable Child...");
   }
}

// Junit Test Case
public class SerializabletTest extends TestCase
{
   public void testIt()
   {
      SerializableParent sp = new SerializableParent();
      SerializableChild sc = new SerializableChild();
      assertEquals(true,sp instanceof Serializable);
      assertEquals(true,sc instanceof Serializable);
   }
}


in the interfaces:
Code:
public interface SerializableInterface extends Serializable
{
}

// Only implements SerializableInterface
public class SerializableInterfaceConcrete implements SerializableInterface
{
   public SerializableInterfaceConcrete()
   {
      super();
      System.out.println("SerializableInterfaceConcrete...");
   }
}

// Junit Test Case
public class SerializabletTest extends TestCase
{
   public void testiConcrete()
   {
      SerializableInterfaceConcrete sic = new SerializableInterfaceConcrete();
      assertEquals(true,sic instanceof Serializable);
   }
}

_________________
http://YuLimin.JavaEye.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 11, 2007 3:56 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This is not a question of "Does it work". It's not a good idea.

http://www.javapractices.com/Topic70.cjp

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.