Re: Enums and iBatis - still not clear

2007-06-13 Thread Paul Benedict




There are two ways of persisting enums. You can persist their name
value or ordinal. A standard solution must allow the developer to
choose the persistence strategy.

Tom Duffey wrote:

  
  On Jun 12, 2007, at 9:32 PM, Paul Benedict wrote:
  
  For each enum you want to write to the
database, you need to write yourself an iBatis type call back handler.
This will translate the enum to whatever data type you want (and int or
a string, etc.), and vice-versa.
  
  
This is more of a developer list question but is there any reason why
we can't make iBATIS handle the simple enum case where the name maps
directly to/from the DB automatically?  It's a major pain to write all
these type handlers.
  
  
  Tom
  
  Sebastian Niezgoda wrote:

Hello,
  
I've read through archives and the wiki but I'm still not clear on how
exactly to handle enums using iBatis.
  
I use ant's xjc task to create objects from a database schema. The code
tables become Java Enum objects such as:
  
public enum MyEnum {
 VAL1,
   VAL2;

   public String value() {
  return name();
   }

   public static MyEnum fromValue(String v) {
  return valueOf(v);
   }
}

I have a POJO, MyObject, with the following parameters:

private String ID;
private MyEnum enum;
  
  
I do a simple query and in the DAO SQL I create a result map as follows:
  

 
   



   

  
  
My question is - how do I map the value I retrieve from db (called
enum) to the MyEnum class?
  
No matter what I replace the ? with it doesn't work and it fails
with the following error:
  
Cause: com.ibatis.common.beans.ProbeException: There is no WRITEABLE
property named '?'; in class 'MyEnum'
  
I could create a bunch of handlers but there are many of them and since
the objects are generated from the schema they can always change.  Is
there an easy way to do this?
  
Thanks,
  
Sebastian
  

  
 

  

  

  
  
  





Re: Enums and iBatis - still not clear

2007-06-12 Thread Paul Benedict




Sebastian,

For each enum you want to write to the database, you need to write
yourself an iBatis type call back handler. This will translate the enum
to whatever data type you want (and int or a string, etc.), and
vice-versa.

Paul

Sebastian Niezgoda wrote:

  
  
Hello,
  
I've read through archives and the wiki but I'm still not clear on how
exactly to handle enums using iBatis.
  
I use ant's xjc task to create objects from a database schema. The code
tables become Java Enum objects such as:
  
public enum MyEnum {
 VAL1,
   VAL2;

   public String value() {
  return name();
   }

   public static MyEnum fromValue(String v) {
  return valueOf(v);
   }
}

I have a POJO, MyObject, with the following parameters:

private String ID;
private MyEnum enum;
  
  
I do a simple query and in the DAO SQL I create a result map as follows:
  

 
   



   

  
  
My question is - how do I map the value I retrieve from db (called
enum) to the MyEnum class?
  
No matter what I replace the ? with it doesn't work and it fails
with the following error:
  
Cause: com.ibatis.common.beans.ProbeException: There is no WRITEABLE
property named '?'; in class 'MyEnum'
  
I could create a bunch of handlers but there are many of them and since
the objects are generated from the schema they can always change.  Is
there an easy way to do this?
  
Thanks,
  
Sebastian
  

  



  

  





Re: How to support read-only fields/paramters

2007-05-07 Thread Paul Benedict

Gordon,

The notion of public, protected, and private are design constructs, not
runtime behaviors. The JVM may have permission to anything it wants, unless
security is installed. I once fell into this trap too :-) It's not pretty.
Just understand that you're read-only interfaces are to help design well,
not to prevent the magic of reflection. Think design, not physical laws of
the universe.

Paul

On 5/7/07, Niels Beekman <[EMAIL PROTECTED]> wrote:


Java Reflection allows to bypass this using
Member.setAccessible(true)...

Niels

-Original Message-
From: Gordon Ross [mailto:[EMAIL PROTECTED]
Sent: maandag 7 mei 2007 11:10
To: user-java@ibatis.apache.org
Subject: RE: How to support read-only fields/paramters

Yes it does help : It works  a treat - but how ?  Private methods are
only accessable from within the class itself, and iBatis is not part of
my class.

GTG

>>> "MCCORMICK, Paul" <[EMAIL PROTECTED]> 05/07/07 8:35 AM
>>>

Ibatis can use the private methods.

E.g.  If you define the method as "private void setId(Integer id) {..}"
then ibatis can call it.

Hope this helps,




Re: iBATIS for Java 2.3.0 General Availability

2007-02-17 Thread Paul Benedict

I am responding on the dev list too :-) There's two things going on:

1) An automated build numbering -- and any build numbering for that 
matter -- isn't needed for official distributions. All you need is the 
X.Y.Z scheme where X=major,Y=minor,Z=revision versions.


2) You are actually using the build numbering to track your snapshots. 
That's what the build number is really for. When you use maven and 
attach -SNAPSHOT suffix to the version number, the libraries get 
deployed to the snapshot repository with an automated build number.


So two things to remember: build numbers are for development 
distributions only. The build number will be updated for every snapshot 
distribution. Once you're ready to attempt an official release, remove 
-SNAPSHOT and then you have the next X.Y.Z version.


Paul

Clinton Begin wrote:
The build number is very important...it's the only automated serial 
number we have.


It doesn't matter to me where that number comes from.  SVN rev number is 
an excellent suggestion.  But I don't want to downplay the importance of 
an automated serial number.


I agree with Jeff's point, that there shouldn't be two releases with the 
same version but different build numbers, and we never have. 

Perhaps a new Ant/Maven task that grabs the revision from the current 
working copy (because that's actually what you're building), but the 
task should also check that there are no modifications...it's a bit 
tricky to get it right actually.  The alternative would be a "fresh 
build" task that would do a full checkout from SVN, note the rev number 
and then build from there.  Which is actually decent.


So to summarize, yes it's important and yes it could be more meaningful 
by using the SVN rev number -- and it has to be automated.


Cheers,
Clinton

On 2/17/07, *Jeff Butler* <[EMAIL PROTECTED] 
> wrote:


I agree that the build number is useless.  Apache policy says that
there are not different versions of a release.  So we really
shouldn't have 2.3.0-638 and 2.3.0-677, we only have one 2.3.0
release (we've only broken that rule one time that I remember).
 
I kind of like the way Derby does it.  The download is just

Derby10.2.2.0, and they add the SVN revision number in the manifest
Bundle-Version property (e.g. 10.2.200.485682).  I haven't
looked at their build to see how they get the SVN number into the
manifest - hopefully it's not a manual hack.
 
I'd like to keep the version number on the name of the JAR file like

we're doing now (ibatis-2.3.0.jar) - just lose the build number.
 
Jeff Butler
 
On 2/17/07, *Larry Meadors* <[EMAIL PROTECTED]

> wrote:

OK, as I am digging through this, I see that we have this "build
number" thing on the download.

I am wondering if we should change it to make that number have
some more value.

What I mean is: "What does 'ibatis-2.3.0.677.zip' really tell me
about
the build?"

677 is just an arbitrary magic number tagged onto the build.

Should we use something like the SVN release number instead?
That way,
I can very easily look to see *exactly* what has changed between
releases by doing this:

  svn diff old:new

That seems a lot more useful than 638 or 677.

Thoughts? I am going to do the next release that way instead
unless I
hear wailing and gnashing of teeth.

Larry





Re: Direct-to-Field mappings now implemented.

2007-02-14 Thread Paul Benedict

Clinton, perhaps you opened the can of worms here :-) But I think the idea
is very good and now we're seeing the feedback necessary to refine the
enhancement. Upon reflection (pun intended), I believe the configuration
option is becoming more and more necessary and so I expand my suggestion to
be a strategy of how to access properties:

propertyStrategy="method|field|method-field"

This attribute be set at the global of resultMap level. With the values
being:
method = only perform method access
field = only perform field access
method-field = perform method access first and then fallback to field




NB: We're going to be doing something similar in Struts 1.4 that specifies
when to populate a form based on the type of request:
populate="request|forward|request-forward"

Paul

On 2/14/07, Brandon Goodin <[EMAIL PROTECTED]> wrote:


Yes, this is a repost... but now that the point has come up...

To avoid the unpredictability of this functionality couldn't we add some
configure options like:

* a diretoryToMappintEnabled=true /false property on the SQL Map Config.
This would set it globally. False would follow strict bean and (eventually)
constructor setting.
* To bring further clarity we should define the lookup order in our docs.
First a setter is attempted and then a property is attempted ( I would
guess)
* Perhaps you could even go as far as placing a reverseLookup=true/false
field on mappings so that the field is examined before the setter this could
be done in the inline and xml based mappings.

Just some thoughts that may provide our usual implicit/explicit options.
Layout the functionality to act in a common known way and provide the
ability to tweak it when needed.


Brandon




Re: Odd behavior with CGLIB

2007-01-26 Thread Paul Benedict

Clinton,

Have you gotten a chance to test out the example? I believe an easy fix 
to the CGLIB proxy could be made.


Paul

Niels Beekman wrote:

We had exactly the same issue, calling a method from within the
constructor triggers "lazy" loading, which obviously isn't very lazy
anymore.

We ended up adding enhancer.setInterceptDuringConstruction(false) where
an Enhancer-object is constructed (2 times in EnhancedLazyResultLoader).

This could however cause problems when you are accessing uninitialized
variables (not loaded from DB), but we're fine with that.

HTH,

Niels

-Original Message-
From: Paul Benedict [mailto:[EMAIL PROTECTED] On Behalf Of
Paul Benedict
Sent: dinsdag 23 januari 2007 5:05
To: User Ibatis
Subject: Odd behavior with CGLIB

Can someone tell me if this is a bug in iBATIS:

I turned on lazy loading of a class. In the constructor of the object, I

called a protected method to initialize some properties. Example:

public MyClassConstructor() {
   setId(-1);
}

Because I called a method, iBATIS marked this class has "loaded" but it 
was never really loaded. Only by replacing setId(-1) with this.id = -1; 
was I able to prevent the "loaded" variable from being immediately set.


I believe there is some sort of sequencing error here. The class should 
not be considered initialized until after the constructor returns.

Thoughts?

Paul

  




Re: Odd behavior with CGLIB (lazy loading problem)

2007-01-24 Thread Paul Benedict

Basically speaking, the lazy-loading query is executing immediately, but the
data is somehow not being set. So I'll query for an "id" property, but the
data doesn't persist. If I remove the code from the constructor which
invokes a method, the data will persist. Go figure! I don't know why, and so
I hope Clinton will be able to help out: I sent him a simple example.

As to Larry's point, calling setters on a field defined on a class is kind
of ancillary. It doesn't have to be setters -- it could be any method. But
if you want to call setters, it is to allow defensive logic to run. Perhaps
you want assertions or other kind of parameter checks in your mutators.

Paul

On 1/24/07, Niels Beekman <[EMAIL PROTECTED]> wrote:


We ran into this issue by trying to reuse parameter validation code. It
can be worked around, but it's still something to be aware of (maybe on
the Wiki?).

Paul has a slightly different problem I think, since our method calls
triggered lazy loading, while Paul cannot load the data at all, if I'm
not mistaken.

Niels



Re: Odd behavior with CGLIB (lazy loading problem)

2007-01-23 Thread Paul Benedict

Clinton,

I have a working example that I can email to you if you're interested. 
Can I email it? Here's a clearer explanation of what Niels and I are 
experiencing:


I have two classes: A which holds an instance of B. I have enhanced lazy 
loading turned on and I query for A with B being lazily loaded. The 
inner callback object which proxies B has a "loaded" boolean property (I 
mistakenly called this "initialized" in the previous email) which 
indicates whether the inner object has been truly loaded or needs to 
execute the query.


If B calls any internal methods in the constructor, which may be 
expected due to data initialization, then "loaded" is immediately marked 
as "true" and the query never executes.


Paul

Niels Beekman wrote:

We had exactly the same issue, calling a method from within the
constructor triggers "lazy" loading, which obviously isn't very lazy
anymore.

We ended up adding enhancer.setInterceptDuringConstruction(false) where
an Enhancer-object is constructed (2 times in EnhancedLazyResultLoader).

This could however cause problems when you are accessing uninitialized
variables (not loaded from DB), but we're fine with that.

HTH,

Niels

-Original Message-
From: Paul Benedict [mailto:[EMAIL PROTECTED] On Behalf Of
Paul Benedict
Sent: dinsdag 23 januari 2007 5:05
To: User Ibatis
Subject: Odd behavior with CGLIB

Can someone tell me if this is a bug in iBATIS:

I turned on lazy loading of a class. In the constructor of the object, I

called a protected method to initialize some properties. Example:

public MyClassConstructor() {
   setId(-1);
}

Because I called a method, iBATIS marked this class has "loaded" but it 
was never really loaded. Only by replacing setId(-1) with this.id = -1; 
was I able to prevent the "loaded" variable from being immediately set.


I believe there is some sort of sequencing error here. The class should 
not be considered initialized until after the constructor returns.

Thoughts?

Paul

  




Odd behavior with CGLIB

2007-01-22 Thread Paul Benedict

Can someone tell me if this is a bug in iBATIS:

I turned on lazy loading of a class. In the constructor of the object, I 
called a protected method to initialize some properties. Example:


public MyClassConstructor() {
  setId(-1);
}

Because I called a method, iBATIS marked this class has "loaded" but it 
was never really loaded. Only by replacing setId(-1) with this.id = -1; 
was I able to prevent the "loaded" variable from being immediately set.


I believe there is some sort of sequencing error here. The class should 
not be considered initialized until after the constructor returns. Thoughts?


Paul


Re: Can ibatis work with java object with constructor have parameters?

2007-01-09 Thread Paul Benedict

Brandon,

I am happy with your response. Yes, I am trying to address a current 
failure in extensibility. I could do something with the RowHandler, 
except it's the wrong point in the lifecycle of the data mapper. A 
RowHandler gives you back an object -- but this is not ideal since I 
need to first determine if I have the object already. So in theory I am 
wasting memory and time to create objects I most likely will be tossing 
away.


You could add to IBATIS this way:

* Allow me to attach a cache at the resultMap level.

* Add a @key attribute to a resultMap. This would flag one or multiple 
properties as being a primary key, and then ibatis could then, if a 
cache is present, check if an object already exists.



...


* Add some other feature to allow flushing of a single object from the 
object cache.


And Tom Duffey writes:

>> Jumping in a little late here but I do exactly this, and I use 
iBATIS *and*

>> I don't require any new iBATIS features.  It's pretty simple:
>> - Turn off iBATIS caching
>> - Build a Factory layer that sites right about your iBATIS layer
>> - Use something like ehcache, oscache, etc. in your factories along 
with

>> some simple methods to ensure object identity

I already do this :-) I front my DAOs with a layer and use OSCache. 
However, this can get very tedious and tough to manage as the # of my 
DAOs grow. If this kind of caching at the object level can be built 
straight into ibatis, life would be easier.


Paul



Re: Can ibatis work with java object with constructor have parameters?

2007-01-08 Thread Paul Benedict

Brandon,

Sometimes it's good to construct the object directly with access to the 
ResultSet, but using IBATIS to dynamically write the SQL. There's a 
ticket open for this functionality:


http://issues.apache.org/jira/browse/IBATIS-226

My driver is because I cache at the object instance level, and return 
the same instance for the same primary key. This is a little deeper than 
ibatis' caching which is at the statement level -- but with multiple 
statements potentially returning the same object (in terms of object 
identity), this is where having access to the ResultSet is necessary. If 
I can shortcut the creation of the object, I will.


Paul

Brandon Goodin wrote:
I'm not completely sure what you are asking. But, if you are asking if 
you can get the ResultSet itself that would be a no. iBATIS is JDBC 
wrapper. If you find that you need more direct access to JDBC then you 
should use JDBC directly.


Brandon

On 1/7/07, *Carfield Yim* <[EMAIL PROTECTED] 
> wrote:


Can I get the reference of resultset when the object is initalizating?

On 1/8/07, Brandon Goodin <[EMAIL PROTECTED]
> wrote:
 > You can find the javadoc here:
 >
 >

http://ibatis.apache.org/docs/java/dev/com/ibatis/sqlmap/engine/mapping/result/ResultObjectFactory.html


 >
 > I was assuming you were wanting to map result values to a
constructor. If
 > you are trying to map results to a constructor, it would seem a
tedious
 > effort to use the ResultObjectFactory for this.
 >
 > I know it is lame that we don't have this functionality. But, we've
 > discussed adding the constructor mapping functionality and have
decided it
 > is best to delay adding it until iB3 (no eta).
 >
 > Brandon
 >
 >
 > On 1/7/07, Carfield Yim <[EMAIL PROTECTED]
> wrote:
 > > I just check for the document and I cannot see those APIs ,
 > > http://ibatis.apache.org/docs/java/user/ , am I looking
 > for wrong
 > > thing?
 > >
 > > On 1/8/07, Goga, Murtaza < [EMAIL PROTECTED]
> wrote:
 > > > Have you considered using an implementation of
ResultObjectFactory?  It
 > can be configured within iBatis or injected into the
SqlMapExecutorDelegate.
 >  Either ways you will have control over the creation and subsequent
 > initialization of objects.
 > > >
 > > > 
 > > >
 > > > From: Peng Wang [mailto: [EMAIL PROTECTED]
]
 > > > Sent: Sun 1/7/2007 9:26 PM
 > > > To: user-java@ibatis.apache.org

 > > > Subject: Re: Can ibatis work with java object with
constructor have
 > parameters?
 > > >
 > > >
 > > > You can do this using Spring. I think iBatis does not have to
support
 > this.
 > > >
 > > >
 > > > On 1/8/07, Carfield Yim < [EMAIL PROTECTED]
 > wrote:
 > > >
 > > > To bad to hear that, is it planned to be implemented?
 > > >
 > > > On 1/8/07, Brandon Goodin < [EMAIL PROTECTED]
> wrote:
 > > > > This is not currently implemented.
 > > > >
 > > > > Brandon
 > > > >
 > > > >
 > > > > On 1/6/07, Carfield Yim < [EMAIL PROTECTED]

 > mailto:[EMAIL PROTECTED]>> > wrote:
 > > > > > I like to pass something to the object while
initalization,
 > can I
 > > > > > specific about that?
 > > > > >
 > > > >
 > > > >
 > > >
 > > >
 > > >
 > > >
 > > >
 > >
 >
 >




Re: Read Only Properties

2007-01-08 Thread Paul Benedict

Jeff,

Can we get this documented in the user guide? :)

Paul

Jeff Butler wrote:
iBATIS can use private getters/setters as of iBATIS 2.2.  I think this 
is better than the interface.
 
Jeff Butler



 
On 1/8/07, *Brett Knights* <[EMAIL PROTECTED] 
> wrote:


Does anyone have a pattern for creating read only fields?

While I am obviously not persisting the RO properties having to have
the
setters as public methods is bad design. Is there any downside(from an
iBatis POV) to exposing an interface as the business class and using a
concrete class for managing persistence (see below) ? Does it seem
pointless to worry about?

interface modelObj{
A getA()
}

class iBatisObj implements modelObj{
public setA(A a);
public A getA();
}




Re: Read Only Properties

2007-01-08 Thread Paul Benedict

Brett,

80% of my model objects have immutable interfaces. It works so good for 
thread-safety. If I ever need to alter an object, my model objects have 
a copy constructor that accept an instance of the interface.


Paul

Brett Knights wrote:

Does anyone have a pattern for creating read only fields?

While I am obviously not persisting the RO properties having to have the 
setters as public methods is bad design. Is there any downside(from an 
iBatis POV) to exposing an interface as the business class and using a 
concrete class for managing persistence (see below) ? Does it seem 
pointless to worry about?


interface modelObj{
A getA()
}

class iBatisObj implements modelObj{
public setA(A a);
public A getA();
}



Inner resultMap

2006-12-28 Thread Paul Benedict
Doing a 1:1 query with IBATIS 2.2.0, I am using an inner resultMap to 
fetch an object. Does anyone know why I am forced to prefix the 
resultMap with the namespace? The example in the Developer Guide (p. 36) 
does not have it that way.


  

  

  


  

PS: Clinton, I believe a good enhancement to retrieving a collection of 
primitives or enums (like above), would be to allow a shortcut as follows:


  
...

  

Paul


ResultMaps for collections of java.lang types (including enum)

2006-12-27 Thread Paul Benedict
I need some help, and the answer I couldn't find in the current sqlmap 
user guide.


I wrote a query which returns a user and its associated roles. The 
resultMap looks like this:



  
  


As you can see, I am grouping by "id" which means I should be collecting 
all my roles in property "roles" which is a List. I already have a 
type handler setup to translate the long into the enum/class, but it's 
not working yet.


While I am using Java 5, this problem is not (I don't think) a Java 5 
problem. I've seen many examples of using the @resultMap attribute on a 
collection to construct the objects to avoid N+1 selects. But what about 
just plain old Java types or enums? How do I map an inner collection of 
Long or String? I don't think it makes sense to use @resultMap because 
there are no Java bean properties to a Long or a String (and in my case 
an enum).


Thanks!!
Paul


Re: How to Do Transaction with JNDI Datasource and Spring Framework?

2006-08-21 Thread Paul Benedict
No. If you use the SqlMapClientDao template, Spring does it all for you. All you will have to do is specify the master sqlmap configuration file in spring and inject it into your dao.Mississippi John Hurt <[EMAIL PROTECTED]> wrote: yuck, so we have to configure that in spring.xml?  i looked last time, not that simple to understand.On 8/21/06, Paul Benedict < [EMAIL PROTECTED]> wrote:Spring installs the ibatis ExternalTransactionManager implementation which has no-op methods. The methods will do nothing, leaving all the transaction management up to the spring
 proxying. Mississippi John Hurt <[EMAIL PROTECTED] > wrote: Anyone have sample spring, ibatis, config with sample code for this?  I'm pretty certain the regular ibatis startTransaction(), endTransaction(), commitTransaction() wont work. Thanks.  Do you Yahoo!? Everyone is raving about the   all-new Yahoo! Mail.   
	
		Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business.


Re: How to Do Transaction with JNDI Datasource and Spring Framework?

2006-08-21 Thread Paul Benedict
Spring installs the ibatis ExternalTransactionManager implementation which has no-op methods. The methods will do nothing, leaving all the transaction management up to the spring proxying.Mississippi John Hurt <[EMAIL PROTECTED]> wrote: Anyone have sample spring, ibatis, config with sample code for this?  I'm pretty certain the regular ibatis startTransaction(), endTransaction(), commitTransaction() wont work. Thanks.  
		Do you Yahoo!? Everyone is raving about the  all-new Yahoo! Mail.

Re: 1.3 set-property key

2006-08-20 Thread Paul Benedict
My bad please ignore. I chose the wrong user group by accident :-) 
		Get your email and more, right on the  new Yahoo.com 


1.3 set-property key

2006-08-20 Thread Paul Benedict
The key attribute of set-property reads:    Since Struts 1.3, an alternate syntax is supported.  By using    the "key" attribute instead of the "property" attribute, you can set     arbitrary string properties on the Config object which is populated    based on the containing element.   NOTE: the "key" attribute is NOT    supported for  inside a  element.I might be glossing over a difference here, but how is this "alternative syntax" better or different than the "property" attribute? It highlights the "arbitrary string properties" feature, but I don't have problems with "property" for the same thing.Paul 
		Do you Yahoo!? 
Get on board. You're invited to try the new Yahoo! Mail Beta.

Re: interface property predicaments

2006-07-11 Thread Paul Benedict
Larry, I am implementing an API. So this is the problem I have to deal with :-(The other guy is right. Ibatis thinks there is no setId on the Person because Person interface is read-only, although in the sqlmap I am constructing a PersonImpl on an ArticleImpl. I believe ibatis can be changed to solve this problem: Assuming that ibatis constructs inner objects as it navigates (does it?), it should use the instance it creates rather than looking at the type from the getter.Otherwise I will have to have a diferent getter on my object just for ibatis that returns the impl.PaulLarry Meadors <[EMAIL PROTECTED]> wrote: So...I do not understand..your beans are interfaces?How often do you swap out the implementation of your beans? ;-)LarryOn 7/10/06, Paul Benedict
 <[EMAIL PROTECTED]> wrote:> I have two interfaces: Article and Person. My problem is with my Article> implementation:>> public interface Article {>   public Person getPerson();> }>> public class ArticleImpl extends Article {>   private Person person;>   public Person getPerson() {> return person;>   }>   public void setPerson(Person person) {> this.person = person;>   }>   // required for ibatis object construction>   public void setPerson(PersonImpl person) {>  this.person = person;>}>  }>> I am using ibatis to construct it as follows:>> > > >> I get that annoying "cannot find WRITABLE property id in Person" message> because it is looks at
 Article.getPerson() which returns the interface not> implementation. But why should that matter? This is wrong behavior, imo. I> know ibatis constructs the inner object first. It will create a PersonImpl,> set property "id" from column "person_id", and then call the setter on> Article.>> Otherwise, I am left believing ibatis cannot work with classes which need to> implement a read-only interface. or someone can recommend the solution,> which I might be unable to find?>> Paul>>>  > How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates.>> 
		Do you Yahoo!? Next-gen email? Have it all with the  all-new Yahoo! Mail Beta.

Re: interface property predicaments

2006-07-10 Thread Paul Benedict
One thing I forgot to mention: the "Article" class listed in my sqlmap is a typeAlias to the actual implementation. Don't think I am trying to construct an interface :-)Paul Benedict <[EMAIL PROTECTED]> wrote: I have two interfaces: Article and Person. My problem is with my Article implementation:public interface Article {  public Person getPerson();}public class ArticleImpl extends Article {  private Person person;  public Person getPerson() {    return person;  }  public void setPerson(Person person) {    this.person = person;  }  // required for ibatis object construction  public void setPerson(PersonImpl person) {     this.person = person;   } }I am using
 ibatis to construct it as follows:    I get that annoying "cannot find WRITABLE property id in Person" message because it is looks at Article.getPerson() which returns the interface not  implementation. But why should that matter? This is wrong behavior, imo. I know ibatis constructs the inner object first. It will create a PersonImpl, set property "id" from column "person_id", and then call the setter on Article. Otherwise, I am left believing ibatis cannot work with classes which need to implement a read-only interface. or someone can recommend the solution, which I might be unable to find?PaulHow low will we go? Check out Yahoo! Messenger’s low 
 PC-to-Phone call rates. 
		Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.

interface property predicaments

2006-07-10 Thread Paul Benedict
I have two interfaces: Article and Person. My problem is with my Article implementation:public interface Article {  public Person getPerson();}public class ArticleImpl extends Article {  private Person person;  public Person getPerson() {    return person;  }  public void setPerson(Person person) {    this.person = person;  }  // required for ibatis object construction  public void setPerson(PersonImpl person) {     this.person = person;   } }I am using ibatis to construct it as follows:    I get that annoying "cannot find WRITABLE property id in Person" message because it is looks at Article.getPerson() which returns the interface not
 implementation. But why should that matter? This is wrong behavior, imo. I know ibatis constructs the inner object first. It will create a PersonImpl, set property "id" from column "person_id", and then call the setter on Article. Otherwise, I am left believing ibatis cannot work with classes which need to implement a read-only interface. or someone can recommend the solution, which I might be unable to find?Paul 
		How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.

Can't find interface (was Re: Possible wrong behavior in ibatis?)

2006-07-04 Thread Paul Benedict
Clinton, I'll write up a class to demonstrate this and submit a JIRA ticket. If 2.2.0 hasn't rolled yet, it would be good to get in.Clinton Begin <[EMAIL PROTECTED]> wrote: It's odd to me that setPerson(Person) doesn't work -- that would be a bug.What is the error you're getting (stack trace)?(As for the "second" -- you can't have overloaded setters, as it violates the JavaBeans spec and stops your beans from working with many tools, including ibatis) Cheers,ClintonOn 7/2/06, Paul Benedict <[EMAIL PROTECTED]> wrote: In my opinion, I came
 across an unexpected behavior in ibatis. I am pretty confident this a bug, but I want to get other people's opinion. Here's my scenario:1) My class PersonImpl is an implementation of the Person interface.  2) An instance of PersonImpl is injected into User.3) An ibatis result map creates a User, a PersonImpl, and sets the PersonImpl into User.I have two problems with #3.First, ibatis forces me to have an explicit setPerson(PersonImpl) -- my setPerson(Person) will not do. Doh! This is peculiar. I believe ibatis should inspect the interfaces of PersonImpl and see if it can match up any interfaces with the setters. Second, I added my explicit setPerson(PersonImpl). That should work, right? Well it doesn't because I still require the overloaded setPerson(Person), and ibatis finds that first and complains about "no WRITABLE property" existing. How do I overcome this problem?PaulTalk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.   Great rates starting at 1�/min.   
		Do you Yahoo!? Next-gen email? Have it all with the  all-new Yahoo! Mail Beta.

Possible wrong behavior in ibatis?

2006-07-02 Thread Paul Benedict
In my opinion, I came across an unexpected behavior in ibatis. I am pretty confident this a bug, but I want to get other people's opinion. Here's my scenario:1) My class PersonImpl is an implementation of the Person interface. 2) An instance of PersonImpl is injected into User.3) An ibatis result map creates a User, a PersonImpl, and sets the PersonImpl into User.I have two problems with #3.First, ibatis forces me to have an explicit setPerson(PersonImpl) -- my setPerson(Person) will not do. Doh! This is peculiar. I believe ibatis should inspect the interfaces of PersonImpl and see if it can match up any interfaces with the setters.Second, I added my explicit setPerson(PersonImpl). That should work, right? Well it doesn't because I still require the overloaded setPerson(Person), and ibatis finds that first and complains about "no WRITABLE property" existing.How do I overcome this problem?Paul 
		Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates starting at 1¢/min.

IBatis Article on javalobby

2006-06-28 Thread Paul Benedict
Javalobby has a nice article today on Ibatis.Handling Joins in IbatisAt 11:05 PM on Jun 27, 2006, R.J. Lorimerhttp://www.javalobby.org/java/forums/t75161.html 
		Do you Yahoo!? 
Get on board. You're invited to try the new Yahoo! Mail Beta.

Re: AW: Obsfucation in iBatis xml file

2006-06-21 Thread Paul Benedict
I believe iBATIS started out as an encryption program, and so I find it ironic I cannot hook in anywhere to do encryption :-) It would be nice if there was a callback so I could wrap one stream in another.iBATIS should have not encryption, but hooks to do that -- or whatever (compression?) -- would be wonderful. Most people like encrypting SQL when stored procedures are not available. You'd be surprised how many companies do only stored procedures because that's considered "unhackable"; not only would you have to get into the web server, but through the internal firewall, and into the DB with a password to read them. With hibernate, the SQL is not generated until runtime, and so it cannot be looked at. But SQL is valuable stuff, it can be years worth of efforts. And some people like to take some zealous steps to make sure it's safe.. it's source code, not binary. PaulClinton Begin <[EMAIL PROTECTED]>
 wrote: What are you protecting though?   -- The SQL?  (why?) -- The Passwords?  (fair enough, but you don't have to put those in the XML file)I've always said that encryption of iBATIS XML files should be outside of the scope of ibatis.  That said, we haven't made it easy for you, as the obvious place to encrypt/decrypt the configuration files is in the Resources utility class -- which is not easily extended or replaced. Perhaps we could offer a configurable a stream filter hook in the Resources class so you can use whatever means you feel comfortable with to encrypt and decrypt your configuration files with.  Thoughts? Trivia:  Who knows the history of the iBATIS name and how it relates to cryptography? 
 Cheers,ClintonOn 6/21/06,  Paul Benedict <[EMAIL PROTECTED]> wrote: Larry, why would it slow me down? :-) Configuration files are read once and thrown away. If it is slower to boot up, oh well, the 2 AM deployment team is going to have to stay up a few more minutes! hehe. But seriously, encrypting the file is only a pre-cautionary safe-guard; decrypting probably also requires a key to be stored somewhere so if that is also found on the file system, I am toast (point granted). But if someone managed to steal the jar only, they can't do a thing. -- Paul Larry Meadors <[EMAIL PROTECTED]> wrote:  You know, if someone has access to your filesystem, encrypting thatfile is just going to slow you down, not them. I would focus on securing the filesystem so that only the one userthat needs access to it has access to it, and letting it protect you.Encrypting that file IMO is a total waste  of time.LarryOn 6/21/06, Paul Benedict  wrote:> Andre, the concern would be if you have to deploy your application to> servers you do not own. Most companies own their servers, but sometimes > small businesses use external providers. -- Paul>>> Andre Peterka  wrote:>>  I have thought
 about encrypting the sqlmaps also. But will it be worth all > the hassle since every RDBMS will provide some kind of monitoring and all> the sqls will be available anyway.>> Andre>> > -Urspr�ngliche Nachricht->> > Von: Paul Benedict [mailto: [EMAIL PROTECTED]]> > Gesendet: Mittwoch, 21. Juni 2006 14:52> > An:  user-java@ibatis.apache.org> > Betreff: Re: Obsfucation in iBatis xml file> >> > I am looking for the same thing. I'd like to encrypt my>  > sqlmap files during my packaging phase. But how to decrypt> > them? I can only imagine with a custom class loader, maybe AspectJ.> >>
 > Tom Henricksen wrote:> >> > We are working on looking into code obfuscation for > > Java application. Is there some way to obfuscate the iBatis> > xml file? My guess is probably not as this would be very difficult.> > Thanks,> > Tom> >> > > >> >> >> > > >> > Do you Yahoo!?> > Everyone is raving about the all-new Yahoo! Mail Beta.> > >  ahoo.com/handraisers>> >>>>>  > How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates.>> Yahoo! Messenger with Voice.  PC-to-Phone calls for ridiculously low rates.   
		Ring'em or ping'em. Make  PC-to-phone calls as low as 1¢/min with Yahoo! Messenger with Voice.

Re: AW: Obsfucation in iBatis xml file

2006-06-21 Thread Paul Benedict
Larry, why would it slow me down? :-) Configuration files are read once and thrown away. If it is slower to boot up, oh well, the 2 AM deployment team is going to have to stay up a few more minutes! hehe. But seriously, encrypting the file is only a pre-cautionary safe-guard; decrypting probably also requires a key to be stored somewhere so if that is also found on the file system, I am toast (point granted). But if someone managed to steal the jar only, they can't do a thing. -- PaulLarry Meadors <[EMAIL PROTECTED]> wrote: You know, if someone has access to your filesystem, encrypting thatfile is just going to slow you down, not them.I would focus on securing the filesystem so that only the one userthat needs access to it has access to it, and letting it protect you.Encrypting that file IMO is a total waste
 of time.LarryOn 6/21/06, Paul Benedict <[EMAIL PROTECTED]> wrote:> Andre, the concern would be if you have to deploy your application to> servers you do not own. Most companies own their servers, but sometimes> small businesses use external providers. -- Paul>>> Andre Peterka <[EMAIL PROTECTED]> wrote:>>  I have thought about encrypting the sqlmaps also. But will it be worth all> the hassle since every RDBMS will provide some kind of monitoring and all> the sqls will be available anyway.>> Andre>> > -Urspr�ngliche Nachricht->> > Von: Paul Benedict [mailto:[EMAIL PROTECTED]> > Gesendet: Mittwoch, 21. Juni 2006 14:52> > An: user-java@ibatis.apache.org> > Betreff: Re: Obsfucation in iBatis xml file> >> > I am looking for the same thing. I'd like to encrypt my>
 > sqlmap files during my packaging phase. But how to decrypt> > them? I can only imagine with a custom class loader, maybe AspectJ.> >> > Tom Henricksen wrote:> >> > We are working on looking into code obfuscation for> > Java application. Is there some way to obfuscate the iBatis> > xml file? My guess is probably not as this would be very difficult.> > Thanks,> > Tom> >> >> >> >> >> > > >> > Do you Yahoo!?> > Everyone is raving about the all-new Yahoo! Mail Beta.> > > ahoo.com/handraisers>> >>>>>  > How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates.>> 
		Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.

Re: AW: Obsfucation in iBatis xml file

2006-06-21 Thread Paul Benedict
Andre, the concern would be if you have to deploy your application to servers you do not own. Most companies own their servers, but sometimes small businesses use external providers. -- PaulAndre Peterka <[EMAIL PROTECTED]> wrote: I have thought about encrypting the sqlmaps also. But will it be worth allthe hassle since every RDBMS will provide some kind of monitoring and allthe sqls will be available anyway.Andre > -Urspr�ngliche Nachricht-----> Von: Paul Benedict [mailto:[EMAIL PROTECTED] > Gesendet: Mittwoch, 21. Juni 2006 14:52> An: user-java@ibatis.apache.org> Betreff: Re: Obsfucation in iBatis xml file> > I am looking for the same thing. I'd like to encrypt my > sqlmap files during my packaging phase. But how to decrypt > them? I can
 only imagine with a custom class loader, maybe AspectJ.> > Tom Henricksen <[EMAIL PROTECTED]> wrote:> >  We are working on looking into code obfuscation for > Java application.  Is there some way to obfuscate the iBatis > xml file?  My guess is probably not as this would be very difficult.>  Thanks,>  Tom>  >  >   > > > > > Do you Yahoo!?> Everyone is raving about the all-new Yahoo! Mail Beta. > > ahoo.com/handraisers> >  
		How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.

Re: Obsfucation in iBatis xml file

2006-06-21 Thread Paul Benedict
I am looking for the same thing. I'd like to encrypt my sqlmap files during my packaging phase. But how to decrypt them? I can only imagine with a custom class loader, maybe AspectJ.Tom Henricksen <[EMAIL PROTECTED]> wrote:  We are
 working on looking into code obfuscation for Java application.  Is there some way to obfuscate the iBatis xml file?  My guess is probably not as this would be very difficult.  Thanks,  Tom  
		Do you Yahoo!? Everyone is raving about the  all-new Yahoo! Mail Beta.

Why writable properties if not being written to?

2006-06-17 Thread Paul Benedict
I have a primary key getter method getId() which exposes the key on my interface. However, I do not have any  statements in which the key would be updated -- because there is no setId() method. So why does IBATIS complain that the WRITABLE property is missing? Paul 
		Ring'em or ping'em. Make  PC-to-phone calls as low as 1¢/min with Yahoo! Messenger with Voice.

Re: specify the database schema in sqlMap?

2005-12-25 Thread Paul Benedict
Thurm,

With iBATIS, you control the query. You only need to specify the schema if 
you're accessing tables
outside the application's preset schema. If you're talking to other schemas, 
then yes you will
have to write out the schema - but 99% of the time I never had to. I usually 
deal with one schema.

Paul




__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 



Re: How to use multiple "groupBy" in resultMap?

2005-12-05 Thread Paul Benedict
Can't you do this? groupBy="{prop1,prop2}" or try without the braces too.




__ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs


Re: Nested Result Sets with inner joins (important!)

2005-11-21 Thread Paul Benedict
My apologies to all on the IBATIS forum :-) My habitual use of "but 
Hibernate can do this" is
not an endorsement of Hibernate, but merely a statement that I use Hibernate at 
work and am
familiar with its feature set. There are some things it can do which I would 
like IBATIS to do
also, but there's also many things IBATIS can do which Hibernate cannot -- such 
as humility, for
one :) Thanks for the mild correction.

--- Clinton Begin <[EMAIL PROTECTED]> wrote:

> That's something we can definitely do.
> 
> But please do me a favourdon't use the "Hibernate can do this" as a
> supporting argument. It's weak and is akin to after-school fights.
> 
> Hibernate is a very different product and the XML configuration goals are
> almost impossible to compare in any way that is sensible.
> 
> Cheers,
> Clinton
> 
> 
> On 11/18/05, Jeff Butler <[EMAIL PROTECTED]> wrote:
> >
> > Wow - synchronicity. This is the same as IBATIS-225 (just filed). I agree
> > that this should be fixed/enhanced. There are some issues, but we should be
> > able to overcome them.
> >  Jeff Butler
> >
> >  On 11/18/05, Paul Benedict <[EMAIL PROTECTED] > wrote:
> > >
> > > Clinton,
> > >
> > > One of the most disappointing aspects of IBATIS has to be the inability
> > > to reuse result maps for
> > > nested properties. IBATIS only allows me to use them if I [1] use
> > > another select or [2] use a
> > > collection. I get this error every time:
> > >
> > > "Error instantiating collection property for mapping 'apple'."
> > >
> > > I ask this because sometimes I need to do joins for efficiency and want
> > > to reuse my resultMap to
> > > populate my inner objects. The user guide talks about how we can use the
> > > nested notation to get
> > > this done, but it's too much work to list out all the properties again.
> > > I would love to see
> > > something like this come along soon:
> > >
> > > 
> > > 
> > > 
> > > 
> > >
> > > 
> > > 
> > > 
> > > 
> > >
> > > This way I can write a select to populate "fruitMap" that joins to APPLE
> > > and ORANGE and use my
> > > existing maps for them to populate them as children of TootyFruit.
> > > --Gotta love the names!
> > >
> > > What do you think? This is very important to me. Hibernate can do this,
> > > why can't we?
> > >
> > > Thanks!
> > > Paul
> > >
> > >
> > >
> > > __
> > > Start your day with Yahoo! - Make it your home page!
> > > http://www.yahoo.com/r/hs
> > >
> >
> >
> 




__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Nested Result Sets with inner joins (important!)

2005-11-17 Thread Paul Benedict
Clinton,

One of the most disappointing aspects of IBATIS has to be the inability to 
reuse result maps for
nested properties. IBATIS only allows me to use them if I [1] use another 
select or [2] use a
collection. I get this error every time:

"Error instantiating collection property for mapping 'apple'."

I ask this because sometimes I need to do joins for efficiency and want to 
reuse my resultMap to
populate my inner objects. The user guide talks about how we can use the nested 
notation to get
this done, but it's too much work to list out all the properties again. I would 
love to see
something like this come along soon:


  
  



  
  


This way I can write a select to populate "fruitMap" that joins to APPLE and 
ORANGE and use my
existing maps for them to populate them as children of TootyFruit. --Gotta love 
the names!

What do you think? This is very important to me. Hibernate can do this, why 
can't we?

Thanks!
Paul



__ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs


Re: Too many methods on a service object

2005-11-11 Thread Paul Benedict
Ron,

Some comments on your worsd:

>>Suppose I have a Person and an Address object. Normally there would be one or 
>>more static
methods on the service object

In Java, the popular method is to create a real object and make instance calls. 
ALot of people
have taken hold to the Spring Framework, which will instantiate singletons of 
whatever class and
then you use those during your app. So here, use singleton instance objects.

> My colleague brought up the point that this can get out of hand (i.e.
> you start getting _a lot_ of methods):

I guess it is what level of tolerance you have. If you are realistic about a 
situation, you will
end up having many methods that all represent real business cases, but I have 
to say some of those
methods below look seriously wrong. There is no reason to have a 
GetManyWithNonNullAddresses and
then a GetManyWithNonCityAddresses method; you should make the choice to return 
ALWAYS full
objects at least one object-depth deep. So, in your case, always return 
addresses if they are one
depth in the object graph. When objects get more complicated and you are 
returning too much data
you will not use, this is where you refactor into nested objects. Here, you can 
then craft methods
to return how many nested objects you want or use iBATIS' autoproxying to run 
SELECT statements on
the nested objects you later hit. I don't have your problem here, and yours can 
be effectively
solve.


> My argument was that those methods wouldn't be written until they
> needed to be used. In other words I wouldn't just be making up random
> methods and never use them

Do not expose any methods your clients will not need. Make the rest private 
until there is a
business case.

> Again, that's not the best example. Imagine the case where I have to
> call through to many service objects until I get my final result. 

There's nothing wrong with service objects relying on other services. However, 
your problem,
again, goes back to your object graph. If you model your objects properly, you 
will understand
that when you SELECT for an object, you take as many levels deep as you think 
you will need
But at least one level deep for simple properties.

> Some other questions I was stumbling on: should the service layer be
> defined through interfaces?

Absolutely. All service objects should be an interface that is implemented. 
Java requires this to
do auto-proxying.

> Should the service layer throw its own ServiceExceptions or just pass
> through the data layer's exception? What happens if the service layer
> just throw up the data exceptions to the presentation layer? The

No. The service layer should not create a wrapper exception just for the sake 
of it. The Spring
Framework philosophy -- which is pretty popular -- is to let all runtime 
exceptions bubble to the
top and only throw checked exceptions if the client can actually recover from 
it. I allow all my
exceptions to go through the roof and then I have a webapp configuration which 
handles the
exceptions for me. BTW, I did do EXACTLY what you're asking and it turned out 
to be a bad idea;
yes, you will have one nice exception to handle but it's a completely useless 
feature. Only throw
custom exceptions if they have real business meanings (UnauthorizedException,
StaleObjectException, etc.) and real business decisions can be made from them. 
Otherwise, let them
go to the sky.

-- Paul




__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


Cache Flushing question

2005-11-10 Thread Paul Benedict
Can the cache be flushed according to a primary key? For instance, the cache 
can be configured to
flush when certain methods are invoked -- but it would be more efficent to 
simply flush the actual
object which has that primary key; and leave the rest of the cache alone.

Any thoughts on this idea?




__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


RE: Cacheing rowless queries?

2005-11-10 Thread Paul Benedict
No. A non-result means the resultMap is not yet attempted to be populated; an 
empty result means
the resultMap was used in a query with no rows returned. The difference between 
a NULL and 0,
effectively. I like your idea anyhow.

--- "Voorhoeve, Niels {PBG}" <[EMAIL PROTECTED]> wrote:

> Well, I guess the key would be the same...based on the query and the
> parameters.  If it returns no rows/objects then put a regular old
> java.lang.Object in the cache.  If it had not been attempted yet or returned
> rows then the key wouldn't be there.  Is that what you meant by non-result
> vs. empty result?
> 
> -Original Message-
> From: Paul Benedict [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, November 10, 2005 6:48 PM
> To: user-java@ibatis.apache.org
> Subject: Re: Cacheing rowless queries?
> 
> Niels,
> 
> That's like a really awesome idea. What kind of marker do you propose to
> determine a non-result
> from an empty result? I would find this super valuable. While you're at it,
> I don't think caching
> works unless you pass in parameters; I have MANY parameterless queries and I
> haven't been able to
> see them get cached yet (stay tuned).
> 
> --- "Voorhoeve, Niels {PBG}" <[EMAIL PROTECTED]> wrote:
> 
> > Hi,
> > 
> > How difficult / desirable would it be to code a feature in the cacheing
> > mechanism to keep track of queries that do not return any objects?  In our
> > case, we end up hitting the database many times for queries that don't
> > return objects.  It would be nice to check a cache of non-results to avoid
> > this extra trip to the db.  I have implemented a work-around to accomplish
> > this in our base dao, but it's not very convenient to use.  
> > 
> > Niels
> > 
> 
> 
> 
>   
> __ 
> Yahoo! FareChase: Search multiple travel sites in one click.
> http://farechase.yahoo.com
> 




__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Re: Cacheing rowless queries?

2005-11-10 Thread Paul Benedict
Niels,

That's like a really awesome idea. What kind of marker do you propose to 
determine a non-result
from an empty result? I would find this super valuable. While you're at it, I 
don't think caching
works unless you pass in parameters; I have MANY parameterless queries and I 
haven't been able to
see them get cached yet (stay tuned).

--- "Voorhoeve, Niels {PBG}" <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> How difficult / desirable would it be to code a feature in the cacheing
> mechanism to keep track of queries that do not return any objects?  In our
> case, we end up hitting the database many times for queries that don't
> return objects.  It would be nice to check a cache of non-results to avoid
> this extra trip to the db.  I have implemented a work-around to accomplish
> this in our base dao, but it's not very convenient to use.  
> 
> Niels
> 




__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Re: oracle hints are treated as comments

2005-11-09 Thread Paul Benedict
I believe the XML spec does not allow the double dash to appear within a body. 
The -- is reserved
for comments. If you're having trouble, wrap a  around your 
statement:


 


--- Guido García Bernardo <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I'm using ibatis sql maps 2.1.5 + Oracle 8, defining the following query
> statement:
> 
> 
> SELECT --+RULE
>id, name, email
>from ...
> 
> 
> The SQL that follows the hint is interpreted as a comment. Thus I get:
> 
> Caused by: java.sql.SQLException: ORA-00936: missing expression
> 
> It works fine when I remove the hint.
> Is ibatis removing line breaks? I think this is a bug or at least an
> undesired behaviour in my case. Is there any workaround or idea?
> 
> Thank you very much,
> 
> -- 
> Guido García Bernardo - [EMAIL PROTECTED]
> Tfn. +34 983 54 89 08
> ITDEUSTO - Valladolid (Spain)
> 





__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


Re: Reload SqlMap xml file

2005-11-09 Thread Paul Benedict
I have the same problem. I've seen this requested before but I don't think 
there is a solution.

--- Ming Xue <[EMAIL PROTECTED]> wrote:

> Hi 
> 
> I am using Spring with SqlMap, the sqlMapClient is configured as a Spring 
> bean, during
> development, I need to modify the sqlMap xml file (actual SQLs) very often, 
> but in order to
> apply the change, I need to restart my Jboss server, so sqlMapClient can 
> reload those xmls. Is
> there a way to reload sqlMap xmls without restarting server (on demand)?
> 
> thanks
> 
> Mingyuan XUE
> Plateau Systems.
> 
> 
>   class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"
> lazy-init="true">
>  
>  
>  
>  
> 




__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Re: iBATIS transactional behaviour

2005-11-08 Thread Paul Benedict
Sreenivasulu,

I have found it best NOT to manage transactions at all; since you're using 
Spring, create a
TransactionProxyFactoryBean which can do it for you; it leads to cleaner code 
and gives you
greater re-use when you need to compound function calls.

As for your question, transactions are on a thread-level. Each new thread gets 
its own
transactional space.

Paul

--- "Konda, Sreenivasulu (Consultant)" <[EMAIL PROTECTED]> wrote:

> Hi All,
>  
> I would like to know expected behaviour of iBATIS JDBC transactions.
> Please see below code snippets and details for the same.
>  
> daoManager.startTransaction();
> insert("insertToTable1", Object1);
> insert("insertToTable2", Object2);
> update("updateTable3", Object3);
> delete("deleteFromTable1", Object1);
> daoManager.commitTransaction();
>  
> Given above sequence of calls, assume that Thread1 is at
> update("updateTable3", Object3) call and Thread2 too entered into the
> same method where above exists.
>  
> Now
>  
> 1) Will Thread2 be able to start another transaction before the tx1 got
> committed to DB, which was started by Thread1?
> 2) If Thread2 starts tx2, what would be the behaviour at DB level in
> this scenario?
> 3) If tx1 and tx2 are allowed simultaneously, is this called as nested
> transaction?
>  
> BTW, transaction manager type is JDB as you see below XML tags from
> sqlmap_config.xml.
>  
> 
> 
>   
> 
>   
>  
> Please let me know your comments.
>  
> Thanks and regards,
> Sreenivas
>  
>  
> 





__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


queryForList

2005-11-07 Thread Paul Benedict
Does this method return an empty list or null if nothing is found?



__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Re: [VOTE] Discontinue Support for: iBATIS Java 1.x, JDK 1.3 and DTDs at ibatis.com

2005-11-06 Thread Paul Benedict
Clinton,

Why are you guys NOT listed on the Apache home page?
You guys are like a stealth project, with a good
following but no props. What's with that? :)

Thanks!
Paul

--- Clinton Begin <[EMAIL PROTECTED]> wrote:

> They're already on apache.org !
> 
> http://ibatis.apache.org/dtd/
> 
> Cheers,
> Clinton
> 
> On 11/6/05, Larry Meadors <[EMAIL PROTECTED]>
> wrote:
> >
> > I am not sure i understand: Will the iBATIS 1.x
> DTDs remain where they
> > are, go away (potentially a very, very bad thing),
> or get moved to
> > apache.org ?
> >
> > Larry
> >
> >
> > On 11/5/05, Clinton Begin
> <[EMAIL PROTECTED]> wrote:
> > > Hi everyone:
> > >
> > > == What? ==
> > >
> > > I'm going to raise a vote and recommend to
> discontinue support for:
> > >
> > > * iBATIS 1.x (including 2.0 compat package)
> > > * All JDKs 1.3 and earlier (and therefore old
> JDBC versions)
> > > * DTDs hosted by iBATIS.com
> > >
> > > == Why? ==
> > >
> > > I'm basing my recommendations on the following
> facts:
> > >
> > > Only 3% of iBATIS users use iBATIS 1.x.
> > > Only 13% of iBATIS users use JDK 1.3.1 or
> earlier
> > > We serve up 1.4 million copies of our DTD every
> month from
> > > ibatis.comwhich is costing me money. :-)
> > >
> > > Discontinuing support for these will allow us to
> move forward with more
> > new
> > > features and lighten the code up a bit.
> > >
> > > == When? ==
> > >
> > > iBATIS 1.x support ends as of version 2.2.0
> (next feature release)
> > > JDK 1.3 and earlier versions support ends as of
> version 2.2.0 (next
> > feature
> > > release)
> > > DTDs hosted at iBATIS.com removed by November
> 30th 2005 as per the
> > > warning[1] that went out in September (90 days
> notice).
> > >
> > > To be proactive, pragmatic and practical, we
> will tag the SVN repository
> > at
> > > version 2.1.6 (next bug fix release). This
> version can then be branched
> > if
> > > necessary to fix any critical issues for those
> living in Bedrock.
> > >
> > > == Who? ==
> > >
> > > Would all PMC members please vote on the three
> items individually
> > >
> > > ( ) iBATIS 1.x is unsupported as of version
> 2.2.0
> > > ( ) JDK 1.3 and earlier are unsupported as of
> version 2.2.0
> > > ( ) DTDs hosted at iBATIS.com are removed as of
> November 30th, 2005.
> > >
> > > Everyone else is free to comment. If you think
> your business will be
> > > significantly impacted by this, please let us
> know.
> > >
> > > Cheers,
> > >
> > > Clinton
> > >
> > >
> > > [1]
> > >
>
http://www.mail-archive.com/user-java@ibatis.apache.org/msg01333.html
> > >
> > >
> >
> 




__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Re: [VOTE] Discontinue Support for: iBATIS Java 1.x, JDK 1.3 and DTDs at ibatis.com

2005-11-06 Thread Paul Benedict
I vote in favor for all except ending support for JDK
1.3 - earlier versions fine, but 1.3 is important.
Wait until you go release 3.0 because major version
changes should be able to break backwards
compatibility in a major way, but not minor releases.
Suddenly switching between 2.1 and 2.3 I think is
really unfair to your loyal 13% customer base. My 2
cents.





__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


Re: iBatis and ORM's

2005-11-05 Thread Paul Benedict
Does iBATIS have a free wiki? There should be a
section for good and bad testimonials. This is one
worth keeping.





__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


Re: Caching (please help)

2005-11-05 Thread Paul Benedict
Clinton,

No luck yet.

Does caching work inside of a nested object too?

Say I have object A with inner objects B and C. I have
the result map for object A call "select" on the
queries for B and C. I have 2 caches respectively
attached to the queries of B and C. Will those be
employed for B and C?

--- Clinton Begin <[EMAIL PROTECTED]> wrote:

> Unfortunately, in order for it to cache, I believe
> you need a parameter. We
> could consider that a bug, albeit rare. But try
> adding a dummy parameter to
> test it.
> 
> Cheers,
> Clinton
> 
> On 11/5/05, Paul Benedict <[EMAIL PROTECTED]>
> wrote:
> >
> > I've spent the last two weeks trying to get the
> > caching to work, but I can confirm iBATIS is not
> > caching any result I configure it for. Obviously
> this
> > isn't anyone else's problem but mine, but I really
> > feel hopeless here and don't know what else to do.
> >
> > Here is my cache:
> > 
> > 
> > 
> > 
> > 
> > 
> >
> > Here is my select:
> >  > cacheModel="namesCache">
> > SELECT id, name FROM names
> > 
> >
> > I have LOG4J turned on for the iBATIS package and
> I
> > can always see it getting a connection, a prepared
> > statement, and the result set. So I know it's not
> > caching. I just call getNames() over and over and
> it
> > never caches.
> >
> > I am using Spring. I know caching is enabled by
> > default, so I don't have any special settings in
> my
> > sql-config.xml. I am bummed out. Can you spot
> anything wrong?
> >
> >
> >
> >
> > __
> > Yahoo! Mail - PC Magazine Editors' Choice 2005
> > http://mail.yahoo.com
> >
> 




__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Caching (please help)

2005-11-05 Thread Paul Benedict
I've spent the last two weeks trying to get the
caching to work, but I can confirm iBATIS is not
caching any result I configure it for. Obviously this
isn't anyone else's problem but mine, but I really
feel hopeless here and don't know what else to do.

Here is my cache:

  
  
  
  


Here is my select:

  SELECT id, name FROM names


I have LOG4J turned on for the iBATIS package and I
can always see it getting a connection, a prepared
statement, and the result set. So I know it's not
caching. I just call getNames() over and over and it
never caches.

I am using Spring. I know caching is enabled by
default, so I don't have any special settings in my
sql-config.xml. I am bummed out. Can you spot anything wrong?




__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


Re: Caching resultMap sub-selects

2005-11-05 Thread Paul Benedict
Michael,

Please submit that as a patch :-) It really bugs me
too. I consider this a must have feature of iBATIS.
Better developer tools encourages greater use of the
product.

Paul

--- Michael Campbell <[EMAIL PROTECTED]>
wrote:

> On 11/5/05, Paul Benedict <[EMAIL PROTECTED]>
> wrote:
> 
> > While it is not clear, I think it is recommending
> to
> > add a cache to the getProductsByCatId method (not
> the
> > parent getCategoryResult). Is that correct? I have
> > many sub-selects and it makes sense to put the
> cache
> > there, the only problem being I can never tell
> when
> > the cache is actually hit - everything always
> seems to
> > go to the DB.
> 
> 
> I think if you see output in your logs that indicate
> the DB is being
> hit, it is.  IIRC, the LACK of logging indicates a
> cache-hit. THis was
> bugging me greatly, so I put in some logging code
> into the cache layer
> for this.
> 




__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Caching resultMap sub-selects

2005-11-05 Thread Paul Benedict
For this example:

 
  
  


The sqlmap guide says:
"The only consideration is that if you were to enable
caching, then the using the separate select (not the
join) solution could result in a cached
instance being returned."

While it is not clear, I think it is recommending to
add a cache to the getProductsByCatId method (not the
parent getCategoryResult). Is that correct? I have
many sub-selects and it makes sense to put the cache
there, the only problem being I can never tell when
the cache is actually hit - everything always seems to
go to the DB.



__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


ResultMap for nested object?

2005-11-03 Thread Paul Benedict
I see examples for getting collections like this:

class Family {
  int id;
  List children;
}


  
  


But what about reusing result maps to retrieve nested
objects? I would like to be able to do something like
the following but I haven't been able to succeed:

class Parent {
  int id;
  Child child;
}


  
  


See? I am trying to reuse the map, but I keep getting
this error instead: "Error instantiating collection
property for mapping 'child'.  Cause:
java.lang.ClassCastException"

Come on iBATIS gurus - show me the answer! :)



__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Re: Bulk inserts

2005-11-03 Thread Paul Benedict
How does it compare to bulk insert? It's faster.
Making 1000 round trips to the database is slower than
1.

Try it out on your database. If it doesn't work, then
you must do a for loop.

--- Michael Campbell <[EMAIL PROTECTED]>
wrote:

> On 11/3/05, Paul Benedict <[EMAIL PROTECTED]>
> wrote:
> > Yes,
> >
> > SQL has a notation to INSERT multiple entries at
> once.
> > What you want to do is build a statement like the
> > following:
> >
> > INSERT INTO fruit (id, name) VALUES (0, 'Pear'),
> (1,
> > 'Apple'), (2, 'Peach')
> 
> 
> Is that standard ANSI SQL?  I know MySql supports
> that syntax, but
> wasn't aware that many (any?) others did.
> 
> --
> I tend to view "truly flexible" by another term:
> "Make everything
> equally hard". -- DHH
> 




__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Re: Bulk inserts

2005-11-02 Thread Paul Benedict
Yes,

SQL has a notation to INSERT multiple entries at once.
What you want to do is build a statement like the
following:

INSERT INTO fruit (id, name) VALUES (0, 'Pear'), (1,
'Apple'), (2, 'Peach')

Use the  tag to build the dynamic list at the
end. In this example, the GroceryBag object has a
property of Fruit[] called fruits:


  INSERT INTO fruit 
(id, name)
  VALUES
  
(#fruits[].id#, #fruits[].name#)
  





__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Re: (tangent) Cache w/ Hierarchical ResultMaps

2005-11-02 Thread Paul Benedict
Larry,

My other option is to say "heck with solving the N+1
problem!" and turn my nested resultMaps into nested
selects. For each object, execute N selects for N
inner objects it would sure clean up my code!

Man, I feel so alone here LOL I am sorry no one else
has really complex queries which requires column
renaming and listing out of the columns.

--- Larry Meadors <[EMAIL PROTECTED]> wrote:

> On 11/2/05, Paul Benedict <[EMAIL PROTECTED]>
> wrote:
> > I could use iBATIS and Hibernate side by side, but
> > that would be an odd combination.
> 
> I have to confess that I was involved in a project
> that did just that.
> 
> For the love of all that is good and right in the
> universe, don't do it.
> 
> It was *that* bad.
> 
> Two frameworks caching data with different
> strategies...two frameworks
> managing transactions differently...two frameworks
> grabbing and
> releasing connections. The pain...the pain...
> 
> Larry
> 




__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Re: (tangent) Cache w/ Hierarchical ResultMaps

2005-11-02 Thread Paul Benedict
So does the iBATIS community recommend I turn to
Hibernate for my kind of situation? Oh, my poor code -
torn between loves :-) I loved everything about iBATIS
until I had to eagerly retrieve complex inner objects
using JOINs. Please inform me if iBATIS offers any
good solution to my problem. I could use iBATIS and
Hibernate side by side, but that would be an odd combination.



__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Re: Cache w/ Hierarchical ResultMaps

2005-11-02 Thread Paul Benedict
I have a DAO interface which is implemented by a
subclass of Spring's SqlMapClientDaoSupport

--- Michael Campbell <[EMAIL PROTECTED]>
wrote:

> Just a general note here...  not every tool is
> suitable for every project.
> iBatis solves a very LARGE set of needs, but it
> might be that it just
> doesn't solve THIS one (it might, but it's sounding
> like not...)
> 
> Good luck in any case, and I wish I had a nifty
> solution for you.
> 
> Out of curiosity, are you using ibatis' daos, or
> rolling your own?
> 
> On 11/2/05, Paul Benedict <[EMAIL PROTECTED]>
> wrote:
> > Reuben (I hope that's your first name :-)),
> >
> > >> Vendor / Branch / Employee / Address
> > >> When I load a Vendor, I wish (if at all
> possible)
> > to load it from the cache, since it contains all
> sub
> > objects (Branch, Employee, Address), and is rather
> > big.
> >
> > I am in the same situation (see my posts about my
> > Fruit object). I am curious about how you feel
> about
> > needing to list out, if you do, all your columns
> for
> > those 4 objects to retrieve a Vendor. This assumes
> > you're not doing 4 selects, but one select using
> > joins.
> >
> > I imagine you have standalone queries like
> findBranch,
> > findEmployee, findAddress which lists out their
> > respective columns, but then you need to list out
> all
> > those columns again for findVendor?
> >
> > I am looking for a good methodology here. I know
> > Hibernate generates the columns to select
> > automatically and I like that because I don't like
> > having to tread through multiple sqlmaps just to
> > update many select statements when things change.
> >
> > What is your take on my concern?
> >
> >
> >
> >
> > __
> > Yahoo! Mail - PC Magazine Editors' Choice 2005
> > http://mail.yahoo.com
> >
> 
> 
> --
> I tend to view "truly flexible" by another term:
> "Make everything
> equally hard". -- DHH
> 





__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


Re: Cache w/ Hierarchical ResultMaps

2005-11-02 Thread Paul Benedict
Reuben (I hope that's your first name :-)),

>> Vendor / Branch / Employee / Address
>> When I load a Vendor, I wish (if at all possible)
to load it from the cache, since it contains all sub
objects (Branch, Employee, Address), and is rather
big.

I am in the same situation (see my posts about my
Fruit object). I am curious about how you feel about
needing to list out, if you do, all your columns for
those 4 objects to retrieve a Vendor. This assumes
you're not doing 4 selects, but one select using
joins.

I imagine you have standalone queries like findBranch,
findEmployee, findAddress which lists out their
respective columns, but then you need to list out all
those columns again for findVendor?

I am looking for a good methodology here. I know
Hibernate generates the columns to select
automatically and I like that because I don't like
having to tread through multiple sqlmaps just to
update many select statements when things change.

What is your take on my concern?




__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


Re: N+1 with column renaming

2005-11-02 Thread Paul Benedict
Larry,

The reason I ask is because my Fruit object actually
contains very important inner objects which must be
retrieved too.

class Fruit {
   Skin s;
   Color c;
   Producer p;
}

These are retrieved everytime and are very important
to the application. I have independent sqlMap selects
which are selectSkin, selectColor, and selectProducer
when I need them as stand-alone objects.

However, when I have to write out all the column names
to retrieve (that's my SQL standard) for all Fruit,
Skin, Color, and Producer -- it sort of makes me
wrench. I love the whole idea that I can reuse my
sqlmap results, but I really don't like the idea that
I have to list out my columns (again): Hibernate would
excel at this task.

What do you think? Am I on track with my commentary or
can you enlighten me with anything further?

THANKS!

--- Larry Meadors <[EMAIL PROTECTED]> wrote:

> I generally name my key fields uniquely, but leave
> the others what
> they are, for example:
> 
> create table Fruit (
>   fruitId int,
>   name varchar(30)
> )
> 
> Then if I join to another table with a "name" field,
> I alias them to
> include the table name (so, in this case i would use
> "fruitName").
> 
> That said..it really does not matter for the N+1
> selects solution,
> becuase it relies on the property names, not the
> field names. :-)
> 
> Larry
> 
> 
> On 11/1/05, Paul Benedict <[EMAIL PROTECTED]>
> wrote:
> > Maybe someone has encountered this problem and
> would
> > like to lend a hand.
> >
> > Many of the tables that I have have column names
> that
> > are not unique across tables. At the moment, I
> have
> > taken the solution to rename each column in my
> query
> > and each resultMap knows what to look for:
> >
> >   
> > 
> > 
> >   
> >
> > So I have the convention that any columns from the
> > Fruit table will be returned as f_, anything from
> the
> > Vegetables column be v_, etc. This then allows me
> to
> > query multiple tables when solving the N+1 problem
> and
> > not get things confused.
> >
> > But is there a better way?
> >
> 





__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


N+1 with column renaming

2005-11-01 Thread Paul Benedict
Maybe someone has encountered this problem and would
like to lend a hand.

Many of the tables that I have have column names that
are not unique across tables. At the moment, I have
taken the solution to rename each column in my query
and each resultMap knows what to look for:

  


  

So I have the convention that any columns from the
Fruit table will be returned as f_, anything from the
Vegetables column be v_, etc. This then allows me to
query multiple tables when solving the N+1 problem and
not get things confused.

But is there a better way?




__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Re: Can I turn transactions off? Help!

2005-10-29 Thread Paul Benedict
Problem solved:

I was hitting a table that was not transactional and
so the data was commited immediately. That's not a
problem with the connection settings, but with me not
being aware of using a non-transactional table type.

Also, I discovered that Spring (in
SqlMapClientFactoryBean) creates an
ExternalTransactionConfig whose implementation is
empty for commiting and rollback. This is very good
:-) So while iBATIS goes through the motions of
commiting, the pluggable implementation that Spring
provides is empty. 

Grreat! :)



__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Can I turn transactions off? Help!

2005-10-29 Thread Paul Benedict
I am a HUGE fan of IBATIS, but suddenly I find myself
in a really bad situation which might force me to dump
it. I am using the Spring Framework to do CMT for me
and I want that to handle my transactions for me --
and this is how I was expecting it, but then I did a
little test:

I threw a NullPointerException after I called insert
after iBATIS and, to my surprise after 2 days of
debugging and stepping through iBATIS code, it's still
committing my transaction! I was expecting Spring to
catch the exception and roll back (which it did), but
I couldn't figure out how it was still comitting. But
then I stepped into iBATIS and saw it's ALWAYS is
commiting. This is unacceptable.

How do I turn off iBATIS from ever committing after an
insert, update, or delete? I do NOT want this to be
handled for me.

Thanks!
Paul



__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com