You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jeff Emminger <je...@jeffemminger.com> on 2003/11/14 21:21:50 UTC

iBatis/Tapestry help?

hi,

I might be asking too much, but here goes:

I'm pretty green still, and I'm building a simple Guestbook application 
to learn iBatis with Tapestry.  It has two pages: "Home" lets you view 
all entries, and "Add" lets you add an entry.  All is well with 
navigating between the two pages.

The trouble I'm having is how and where to implement the getters/setters 
for new and existing Guestbook entries.  I've created a GuestbookEntry 
class with properties id, author and comments, and a SqlMap for 
selecting all from or inserting into the corresponding mySql table.  (a 
GuestbookSqlMapConfig class handles dispensing a SqlMap object to 
execute my queries)

For instance, on my Home page I want to select all entries and display 
via a Foreach, so I've done this:

Home.html:
<!-- a Border component handles <html> and <body> and nav links -->
<span jwcid="border">
	<div jwcid="e">
		<span jwcid="insertAuthor">Author:</span>
		<br/>
		<span jwcid="insertComments">Comments</span>
	</div>
</span>

Home.page:
<page-specification class="guestbook.Home">
	<component id="border" type="Border">
		<static-binding name="title" value="View Guestbook"/>
		<binding name="pages" expression="engine.pageNames"/>
	</component>
	<component id="e" type="Foreach">
		<binding name="source" expression="guestbookEntry"/>
		<binding name="value" expression="guestbookEntry"/>
	</component>
	<component id="insertAuthor" type="Insert">
		<binding name="value" expression="author"/>
	</component>
	<component id="insertComments" type="Insert">
		<binding name="value" expression="comments"/>
	</component>
</page-specification>

Home.java:
public class Home extends BasePage {
	private GuestbookEntry entry = new GuestbookEntry();
	
	public GuestbookEntry getGuestbookEntry() {
		return entry;
	}
	public void setGuestbookEntry()
		throws SQLException {
		SqlMap sqlMap = GuestbookSqlMapConfig.getSqlMapInstance();
		entry = 
(GuestbookEntry)sqlMap.executeQueryForObject("getGuestbookEntries", null);
	}
	
	public String getAuthor() {
		return entry.getAuthor();
	}
	public String getComments() {
		return entry.getComments();
	}
}


Now when I run the app, I get the error "Unable to update expression 
'guestbookEntry' for guestbook.Home@bb6086[Home] to 
guestbook.GuestbookEntry@7616ad.
binding: 	ExpressionBinding[Home guestbookEntry]"

Can anyone offer any pointers?

Thanks,
Jeff



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: iBatis/Tapestry help?

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Hibernate is certainly better if you are looking for transparent persistence and that means 
concurrency and session management. iBatis has no support in this area becasue it is NOT a 
transparent persistence framework. The beauty with iBatis is you have complete control over your SQL 
and the caching (yes iBatis has an internal configurable cache and also supports OsCache). I am not 
familiar with HQL so can't compare it. I don't think writing insert and update statements is that 
big of a deal as compared to writing select statements. With Hibernate although you don't have to 
write the statements you still have to provide the mapping files for it to work with. And finally 
with iBatis you can compose a class however and from whatever you want. So the question really is 
"what is the need of the application?". If you have legacy databases or poorly designed databases or 
you want to use some proprietary sql extensions and you are willing to work at a lower level in 
terms of caching, concurrency and session management then iBatis may be for you. OTOH, if your team 
lacks sql skills and prefers an ORM framework, Hibernate may be for you.

Just my opinion.

-Harish

Kevin C. Dorff wrote:
> iBatis lets you write SQL statements that tie to objects. Hibernate 
> doesn't really require you to write any Sql, you may write some HQL 
> (hibernate query language) for retrieval.
> 
> Insert's and update's are free with Hibernate. You don't need to write a 
> single update or insert statement once you switch to Hibernate.
> 
> You can easily compose a class from multiple tables with hibernate, 
> including if a class contains a collection of data that comes from 
> another table. Then, make changes to the classes or sub collection 
> (incluiding add, edit, remove objects in the collection) then when you 
> save all the appropriate tables get updated.
> 
> There are at least two pluggable caching architectures that work within 
> Hibernate (2.1) to speed up access. Pretty neat.
> 
> Hibernate is a MUCH larger scope project than iBatis (I am not slamming 
> iBatis, it is a cool thing, it would be easier to convert an existing 
> application to use iBatis but Hibernate does a LOT more).
> 
> Kevin
> 
> Bill Lear wrote:
> 
>> On Friday, November 14, 2003 at 13:28:42 (-0700) Kevin C. Dorff writes:
>>  
>>
>>> Just an FYI, we looked at iBatis and went with Hibernate. It does 
>>> more for you. If what you need is solved by iBatis then go for it, I 
>>> thought it was pretty cool when I looked at it.
>>>   
>>
>>
>> What exactly did you find lacking in iBatis?
>>
>>
>> Bill
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>  
>>
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: iBatis/Tapestry help?

Posted by "Kevin C. Dorff" <kd...@kcp.com>.
iBatis lets you write SQL statements that tie to objects. Hibernate 
doesn't really require you to write any Sql, you may write some HQL 
(hibernate query language) for retrieval.

Insert's and update's are free with Hibernate. You don't need to write a 
single update or insert statement once you switch to Hibernate.

You can easily compose a class from multiple tables with hibernate, 
including if a class contains a collection of data that comes from 
another table. Then, make changes to the classes or sub collection 
(incluiding add, edit, remove objects in the collection) then when you 
save all the appropriate tables get updated.

There are at least two pluggable caching architectures that work within 
Hibernate (2.1) to speed up access. Pretty neat.

Hibernate is a MUCH larger scope project than iBatis (I am not slamming 
iBatis, it is a cool thing, it would be easier to convert an existing 
application to use iBatis but Hibernate does a LOT more).

Kevin

Bill Lear wrote:

>On Friday, November 14, 2003 at 13:28:42 (-0700) Kevin C. Dorff writes:
>  
>
>>Just an FYI, we looked at iBatis and went with Hibernate. It does more 
>>for you. If what you need is solved by iBatis then go for it, I thought 
>>it was pretty cool when I looked at it.
>>    
>>
>
>What exactly did you find lacking in iBatis?
>
>
>Bill
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>  
>




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: iBatis/Tapestry help?

Posted by Bill Lear <ra...@zopyra.com>.
On Friday, November 14, 2003 at 13:28:42 (-0700) Kevin C. Dorff writes:
>Just an FYI, we looked at iBatis and went with Hibernate. It does more 
>for you. If what you need is solved by iBatis then go for it, I thought 
>it was pretty cool when I looked at it.

What exactly did you find lacking in iBatis?


Bill

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: iBatis/Tapestry help?

Posted by "Kevin C. Dorff" <kd...@kcp.com>.
Just an FYI, we looked at iBatis and went with Hibernate. It does more 
for you. If what you need is solved by iBatis then go for it, I thought 
it was pretty cool when I looked at it.

Kevin

Jeff Emminger wrote:

> hi,
>
> I might be asking too much, but here goes:
>
> I'm pretty green still, and I'm building a simple Guestbook 
> application to learn iBatis with Tapestry.  It has two pages: "Home" 
> lets you view all entries, and "Add" lets you add an entry.  All is 
> well with navigating between the two pages.
>
> The trouble I'm having is how and where to implement the 
> getters/setters for new and existing Guestbook entries.  I've created 
> a GuestbookEntry class with properties id, author and comments, and a 
> SqlMap for selecting all from or inserting into the corresponding 
> mySql table.  (a GuestbookSqlMapConfig class handles dispensing a 
> SqlMap object to execute my queries)
>
> For instance, on my Home page I want to select all entries and display 
> via a Foreach, so I've done this:
>
> Home.html:
> <!-- a Border component handles <html> and <body> and nav links -->
> <span jwcid="border">
>     <div jwcid="e">
>         <span jwcid="insertAuthor">Author:</span>
>         <br/>
>         <span jwcid="insertComments">Comments</span>
>     </div>
> </span>
>
> Home.page:
> <page-specification class="guestbook.Home">
>     <component id="border" type="Border">
>         <static-binding name="title" value="View Guestbook"/>
>         <binding name="pages" expression="engine.pageNames"/>
>     </component>
>     <component id="e" type="Foreach">
>         <binding name="source" expression="guestbookEntry"/>
>         <binding name="value" expression="guestbookEntry"/>
>     </component>
>     <component id="insertAuthor" type="Insert">
>         <binding name="value" expression="author"/>
>     </component>
>     <component id="insertComments" type="Insert">
>         <binding name="value" expression="comments"/>
>     </component>
> </page-specification>
>
> Home.java:
> public class Home extends BasePage {
>     private GuestbookEntry entry = new GuestbookEntry();
>     
>     public GuestbookEntry getGuestbookEntry() {
>         return entry;
>     }
>     public void setGuestbookEntry()
>         throws SQLException {
>         SqlMap sqlMap = GuestbookSqlMapConfig.getSqlMapInstance();
>         entry = 
> (GuestbookEntry)sqlMap.executeQueryForObject("getGuestbookEntries", 
> null);
>     }
>     
>     public String getAuthor() {
>         return entry.getAuthor();
>     }
>     public String getComments() {
>         return entry.getComments();
>     }
> }
>
>
> Now when I run the app, I get the error "Unable to update expression 
> 'guestbookEntry' for guestbook.Home@bb6086[Home] to 
> guestbook.GuestbookEntry@7616ad.
> binding:     ExpressionBinding[Home guestbookEntry]"
>
> Can anyone offer any pointers?
>
> Thanks,
> Jeff
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org