ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher.Mathru...@sybase.com
Subject RE: Abator wishlist
Date Fri, 23 Jun 2006 17:14:23 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META boundary="----=_Part_27934_2130886.1151082089738" alternative; multipart 
Content-Type:>
<META charset=ISO-8859-1 Content-Type: 
------="_Part_27934_2130886.1151082089738" inline Content-Disposition: html; 
text quoted-printable Content-Transfer-Encoding:>
<META content="MSHTML 6.00.2900.2912" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=743580517-23062006><FONT color=#0000ff

size=2>Very well stated Jeff, and I like your suggested 
implementation.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=743580517-23062006><FONT color=#0000ff

size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=743580517-23062006><FONT color=#0000ff

size=2>To add more to the argument of having separate PrimaryKey classes, my 
last project we I was using EJB's for persistence and started by using the 
simple Java wrapper classes around the primitives, such as Integer for int and 
of course String. Seemed like the correct thing to do, after all why would you 
write a wrapper around these classes? That question I answered rather quickly 
when several months into the project we needed to change the datatypes of the 
primary key field on several of the tables from String to Integer. Because I 
used these classes as the PrimaryKey of the object I needed to touch all of the 
code that made reference to the PrimaryKey field of the entity objects. What a 
painful experience. While I had WSAD to facilitate these changes, it was still 
painful and did nothing to help the changes that needed to be made to all of the 
JSP's. Had we a PrimaryKey class in the first place the impact would have been 
greatly reduced and almost negligible. </FONT></SPAN><SPAN 
class=743580517-23062006><FONT color=#0000ff size=2>I learned my lesson and now 
always create a PrimaryKey class for every Domain object. And as you stated 
below, it provides a much cleaner interface to the selectByPrimaryKey and 
deleteByPrimaryKey methods.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=743580517-23062006><FONT color=#0000ff

size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=743580517-23062006><FONT color=#0000ff

size=2>Thanks for all the hard work Jeff. It's greatly 
appreciated.</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> "Jeff Butler" 
&lt;jeffgbutler@gmail.com&gt; [mailto:"Jeff Butler" 
&lt;jeffgbutler@gmail.com&gt;] <BR><B>Sent:</B> Friday, June 23,
2006 10:01 
AM<BR><B>To:</B> user-java@ibatis.apache.org<BR><B>Subject:</B>
Re: Abator 
wishlist<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV>The primary key class is seperated so that the method signatures for 
selectByPrimaryKey and deleteByPrimaryKey can only require the primary key, and 
not the class that represents the entire row.&nbsp; I did it that way because I 
have strong dislike of&nbsp;using half empty objects.&nbsp; For example,&nbsp;if

the deleteByPrimaryKey method took the entire row as a parameter, everyone would 
have to remember what fields are in the primary key and only set those fields - 
yuck.&nbsp; For the same reason, Abator will generate a seperate class that just 
contains any BLOB fields that are in the table. </DIV>
<DIV>&nbsp;</DIV>
<DIV>Here are some thought on the other suggestions:</DIV>
<DIV>&nbsp;</DIV>
<DIV>1. generate a selectAll method -&nbsp;easy.</DIV>
<DIV>&nbsp;</DIV>
<DIV>2. Override the naming convention for DAO methods - probably not too 
difficult,&nbsp;I'll look into it further</DIV>
<DIV>&nbsp;</DIV>
<DIV>3. Pseudo primary keys - you can write your own selectByTeamId type of 
methods now using the example class.&nbsp; I write extra DAO methods like this 
all the time in my projects.&nbsp; You could write your own updateByTeamId 
method if I implement an updateByExample method (which I hope to do).&nbsp; I 
understand that you're not too excited about the example methods because they 
might be hard to duplicate in other frameworks - but why would you ever want to 
use another framework? :-)&nbsp; However, if you just used the example classes 
internally to your DAO and added the extra methods you wanted then you could do 
whatever you need to do.&nbsp; I could add an option to make the by example 
methods private in the DAO classes so that no programmer would be tempted to use 
them directly.&nbsp; Then you could just use them internally. </DIV>
<DIV>&nbsp;</DIV>
<DIV>Thoughts???</DIV>
<DIV>Jeff Butler</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;</DIV>
<DIV><SPAN class=gmail_quote>On 6/23/06, <B class=gmail_sendername><A

href="mailto:erlend.bjorge@aftenposten.no">erlend.bjorge@aftenposten.no</A></B>

&lt;<A href="mailto:erlend.bjorge@aftenposten.no">erlend.bjorge@aftenposten.no 
</A>&gt; wrote:</SPAN> 
<BLOCKQUOTE class=gmail_quote 
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
  <DIV>
  <DIV lang=NO-BOK link="blue" vlink="purple">
  <DIV>
  <P><FONT face=Arial color=navy size=2><SPAN 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Hi 
  there!</SPAN></FONT></P>
  <DIV></DIV>
  <DIV><SPAN class=q>
  <P><FONT face=Courier color=navy size=3><SPAN 
  style="FONT-SIZE: 12pt; COLOR: navy; FONT-FAMILY: Courier"></SPAN></FONT>&nbsp;</P>
  <P><FONT face=Courier color=navy size=3><SPAN lang=EN-GB 
  style="FONT-SIZE: 12pt; COLOR: navy; FONT-FAMILY: Courier">&gt;Gareth 
  wrote:</SPAN></FONT><FONT face=Courier><SPAN lang=EN-GB 
  style="FONT-FAMILY: Courier"> <BR><FONT color=navy><SPAN 
  style="COLOR: navy">&gt;</SPAN></FONT>Most of the hand written domain
objects 
  I have are completely flat POJOs - there is no separate class for primary key 
  - most of the time, there are no <FONT color=navy><SPAN 
  style="COLOR: navy">&gt;</SPAN></FONT>primary keys on the database -
so I'd 
  like all of the Abator generated objects to be the same. Can we turn off 
  generation of primary key classes for those <FONT color=navy><SPAN 
  style="COLOR: navy">&gt;</SPAN></FONT>tables where primary keys are present

  and just use flat objects?<FONT color=navy><SPAN 
  style="COLOR: navy"></SPAN></FONT></SPAN></FONT></P>
  <P><FONT face=Arial color=navy size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P></SPAN></DIV>
  <DIV>
  <P><FONT face=Arial color=navy size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">I have been using 
  Ibatis for 2 years (and Hibernate for 1 year) now and I'm not sure why you 
  "want" to have separate primary key classes for your model beans ? 
  </SPAN></FONT></P>
  <P><FONT face=Arial color=navy size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Not sure why that 
  should be good for ? News for me, can anyone tell me why ? </SPAN></FONT><FONT

  face=Wingdings color=navy size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Wingdings">J</SPAN></FONT><FONT

  face=Arial color=navy size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> </SPAN></FONT></P>
  <P><FONT face=Arial color=navy size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P>
  <P><FONT face=Arial color=navy size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Btw, not heard about 
  Abator before, that sound interesting </SPAN></FONT><FONT face=Wingdings

  color=navy size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Wingdings">J</SPAN></FONT><FONT

  face=Arial color=navy size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"></SPAN></FONT> </P>
  <P><FONT face=Arial color=navy size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P>
  <P><FONT face=Arial color=navy size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Thanks,</SPAN></FONT></P>
  <P><FONT face=Arial color=navy size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Erlend 
  Bjørge</SPAN></FONT></P>
  <P><FONT face=Courier size=3><SPAN lang=EN-GB 
  style="FONT-SIZE: 12pt; FONT-FAMILY: Courier"><BR><BR><BR></SPAN></FONT></P></DIV></DIV></DIV></DIV></BLOCKQUOTE></DIV><BR></BODY></HTML>


Mime
View raw message