• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Entity inheritance and sorting: Bug or my fault?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Entity inheritance and sorting: Bug or my fault?


  • Subject: Re: Entity inheritance and sorting: Bug or my fault?
  • From: Ian Joyner <email@hidden>
  • Date: Mon, 10 Jul 2006 10:34:11 +1000

Hi Guido,

I'm a bit uneasy about your design having as types CONTACT, USER, LIST and then CONTACT_LIST and USER_LIST. This does not suggest inheritance, but (for those who have used languages with genericity) a generic type. Thus you would have a single type LIST with a generic type parameter: LIST [X]. When using a LIST, you provide the actual generic type that the LIST will contain: LIST [CONTACT], LIST [USER], saying list of contacts and list of users respectively. You can also constrain the generic types, eg BOTTLE [X -> LIQUID] where an actual bottle can only be instantiated with LIQUID or a subclass of liquid.

In Java, there is no genericity, so one must use a type cast at runtime to retrieve elements. This has several disadvantages: 1) that any error made is only picked up at runtime, rather than at compile time (resulting in the all too familliar ClassCastException); and 2) you have to put casts all over the place in code, whereas with genericity, you have a one time only specification in the declaration (the advantage of declarative languages). The generic approach is better where you have the common case where two inheritance hierarchies are interdependent, but you don't want to have another class just because you have different types put in your generic container.

Unfortunately, type casting is the best we can do in Java at the moment, until genericity becomes properly implemented in Java (and widespread in the JVM). I can see you want a stronger design, but this is not possible in Java.

HTH

Ian

On 10/07/2006, at 12:45 AM, Guido Neitzer wrote:

Hi.

I found a small problem with entity inheritance, which I don't understand. I hope my explanation is not too bad because I hope to get some enlightening comments here ...

I have a base component called "EmbeddedList" that takes an entity name and an initial fetch specification and uses this to build a displayGroup of the objects in the database.

Now, I have the following inheritance in my model:

Contact
	- Company
	- Person
		- InternalUser

So, everything inherits from Contact, but InternalUser is a bit deeper, it inherits from Person.

Now I have two different list components, both extending EmbeddedList. The first ("ContactList") uses "Contact" as its entityName, the second ("UserList") uses "InternalUser" as its entityName.

The fetch specification for both is exactly the same and uses a sortOrdering which orders not on an attribute but on a calculated value called "name". Each Subentity has a method "public String name ()" which returns some appropriate value.

When I use this fetch specification now on my first list with the entity "Contact" it works just fine. When I use it on the second list with the entity "InternalUser" it fails because it tries to generate a sql order by clause for "name" and this fails (as expected).

Why is this the case? Okay, I can see that it might not be a good idea to set a sort ordering on a "non attribute key" in the fetch spec, but why does it work in one case and fails to work in the other?

cug

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40sportstec.com


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Entity inheritance and sorting: Bug or my fault?
      • From: Guido Neitzer <email@hidden>
References: 
 >Entity inheritance and sorting: Bug or my fault? (From: Guido Neitzer <email@hidden>)

  • Prev by Date: Re: Entity inheritance and sorting: Bug or my fault?
  • Next by Date: Re: Entity inheritance and sorting: Bug or my fault?
  • Previous by thread: Re: Entity inheritance and sorting: Bug or my fault?
  • Next by thread: Re: Entity inheritance and sorting: Bug or my fault?
  • Index(es):
    • Date
    • Thread