ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Spencer <pau...@apache.org>
Subject Is their a default @Case in @TypeDiscriminator ?
Date Tue, 02 Mar 2010 17:04:26 GMT
iBatis 3.0-Beta-9

Is there a default @Case in @TypeDiscriminator?

I need this* for the following reasons:
1) Remove the need to update the annotation when a new discriminator value, that would use
the default type, is added to the database.
2) Remove the need to alter the SQL so a NULL discriminator value is not returned.
3) Use an Interface in the type definition of the returned objects.  Although I currently
use an Interface in the definition, I am forced to include a @Case for all possible values.

Below is an example of my existing code:

> @TypeDiscriminator(javaType = String.class, cases = {
> 			@Case(type = AccountSummaryDefaultImpl.class, value = ""),
> 			@Case(type = AccountSummaryAImpl.class, value = "A"),
> 			@Case(type = AccountSummaryDefaultImpl.class, value = "B"),
> 			@Case(type = AccountSummaryDefaultImpl.class, value = "C"),
> 			@Case(type = AccountSummaryDefaultImpl.class, value = "D") }, column = "accountType")

>  List<AccountSummaryInterface> selectAccountSummaries( Map<String, Object>
queryParameters); } 
> 

Desired code utilizing a default type, as define by the attribute defaultType.
> 
> @TypeDiscriminator(javaType = String.class, cases = {
> 			@Case(type = AccountSummaryAImpl.class, value = "A"),
> 			@Case(defaultType = AccountSummaryDefaultImpl.class) }, column = "accountType")
>  List<AccountSummaryInterface> selectAccountSummaries( Map<String, Object>
queryParameters); } 


* I am open to other solutions.

Paul Spencer
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message