Login

mvnForum

mvnForum Homepage Welcome Guest
  Search  
  Index  | Recent Threads  | Unanswered Threads  | List Polls  | Public Albums  | Who's Online  | Help


Quick Go »


No member browsing this thread
Thread Status: Active
Total posts in this thread: 9
Post new Thread
Author
Previous Thread This topic has been viewed 2500 times and has 8 replies Next Thread
Male chip33550336
Newbie




Joined: May 14, 2003
Post Count: 20
Status: Offline
Reply to this Post  Reply with Quote 
http://db.apache.org/torque/

Have you looked at Torque as an option?

It is simple and easy to use, and takes all the hassel out of moving from one database (e.g. Oracle) to another (e.g. mysql)

Generator :
---------------
-It creates the database. [ant]
-It creates all the tables. [ant]
-It will populate the tables with initial values. [ant]
-stores the schema in an xml format for database portability. [you-edit]

Runtime:
-----------
-can use various jdbc connection pools and/or jndi datasources.
-generates an encapsulated java object persistence layer that is very easy to use.

Admittedly, I have no Hibernate experience, but I do know that Torque seems to solve most the problems you are talking of.


=============================================
Here is a simple example (schema, followed by simple code use) :

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE database SYSTEM
"http://db.apache.org/torque/dtd/database_3_1.dtd">

<database
name="metric"
defaultIdMethod="idbroker">

<table name="task">
<column
name="id"
required="true"
primaryKey="true"
autoIncrement="true"
type="INTEGER"/>
<column
name="name"
required="true"
type="VARCHAR"
size="255"/>
<column
name="description"
required="false"
type="LONGVARCHAR"/>
<column
name="category_id"
required="true"
type="INTEGER"/>
<column
name="date_created"
required="true"
type="TIMESTAMP"/>
<foreign-key foreignTable="category">
<reference
local="category_id"
foreign="id"/>
</foreign-key>
</table>

<table name="category">
<column
name="id"
required="true"
primaryKey="true"
autoIncrement="true"
type="INTEGER"/>
<column
name="name"
required="true"
type="VARCHAR"
size="255"/>
<column
name="description"
required="false"
type="LONGVARCHAR"/>
<unique>
<unique-column name="name"/>
</unique>
<foreign-key foreignTable="task">
<reference
local="id"
foreign="category_id"/>
</foreign-key>
</table>

</database>




import gnu.metric.torque.Category;
import gnu.metric.torque.CategoryPeer;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.apache.torque.util.Criteria;

public class CategoryAction extends DispatchAction {

private static final Criteria criteria = new Criteria();

public ActionForward display(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

List categories = CategoryPeer.doSelect(criteria);
request.setAttribute("categories", categories);
return mapping.findForward("category");
}
public ActionForward add(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

Category category = new Category();
category.setName(request.getParameter("name"));
category.setDescription(request.getParameter("description"));
category.save();
return display(mapping, form, request, response);
}

public ActionForward delete(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

String id = request.getParameter("id");
Criteria criteria = new Criteria();
criteria.add(CategoryPeer.ID, id);
CategoryPeer.doDelete(criteria);

return display(mapping, form, request, response);
}
}
[Jan 8, 2004 9:26:49 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male chip33550336
Newbie




Joined: May 14, 2003
Post Count: 20
Status: Offline
Reply to this Post  Reply with Quote 
Re: http://db.apache.org/torque/

here is an article that sums up the differences better than I could

http://www.mail-archive.com/torque-user@db.apache.org/msg00792.html
[Jan 8, 2004 9:37:15 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male minhnn
mvnForum Developer
Member's Avatar

Vietnam
Joined: Oct 16, 2002
Post Count: 2956
Status: Offline
Reply to this Post  Reply with Quote 
Re: http://db.apache.org/torque/

From your link I found this:
I've used both and they are both good for different things. It's easier to get up and running with Torque, because it's simpler and doesn't try to do as much. On the other hand, with more complex projects, Hibernate may be better.

I think Hibernate is more mature and feature-rich than Forque smile
----------------------------------------
Minh Nguyen
mvnForum Developer
Want a free, open source Java Jsp/Servlet forum, get mvnForum at http://www.mvnForum.com

http://www.DienDanLinux.org
[Jan 9, 2004 1:06:21 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest    http://www.MyVietnam.net    minhnn_mvn [Link] Report threatening or abusive post: please login first  Go to top 
Male dejan
mvnForum Developer




Joined: Feb 27, 2003
Post Count: 185
Status: Offline
Reply to this Post  Reply with Quote 
Re: http://db.apache.org/torque/

Hibernate is probably the most popular ORM today. I have used it on few project and I also have analyzed few Torque projects but I am pretty sure that Hibernate would be much better solution for mvnForum than Torque. Since Hibernate persists POJOs (no need for extending/implementing Hibernate classes/interfaces) it would be much easer to isolate Hibernate code in DAO classes. On the other hand Torque needs few different classes (4 as I can remember) per table and they are Torque specific.
[Jan 9, 2004 9:05:46 PM] Show Printable Version of Post    View Member Profile    Send Private Message    dejan_krsmanovic    76119246 [Link] Report threatening or abusive post: please login first  Go to top 
Male chip33550336
Newbie




Joined: May 14, 2003
Post Count: 20
Status: Offline
Reply to this Post  Reply with Quote 
Re: http://db.apache.org/torque/

I think I will check Hibernate out then.

When just inserting new data (with Torque) it just uses the Bean Object that represents the table. In this case you just need to use one object. For the example of a "category table" :

<code>
Category category = new Category();
category.setName(request.getParameter("name"));
category.setDescription(request.getParameter("description"));
category.save();
</code>

And if you want to do a select, delete, or update you use the Peer class and the Bean. And if you want a where clause you have to use the Criteria object. Three objects needed for a delete with a where clause.

<code>
Criteria criteria = new Criteria();
criteria.add(CategoryPeer.ID, id);
CategoryPeer.doDelete(criteria);
</code>
[Jan 10, 2004 11:30:19 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male murrumbeena
Newbie




Joined: Dec 6, 2003
Post Count: 20
Status: Offline
Reply to this Post  Reply with Quote 
Re: http://db.apache.org/torque/

Hibernate is probably the most popular ORM today. I have used it on few project and I also have analyzed few Torque projects but I am pretty sure that Hibernate would be much better solution for mvnForum than Torque. Since Hibernate persists POJOs (no need for extending/implementing Hibernate classes/interfaces) it would be much easer to isolate Hibernate code in DAO classes. On the other hand Torque needs few different classes (4 as I can remember) per table and they are Torque specific.

yes , torque will generate 4 clazz, (base and peer..)
and i think the seriousest problem is torque lacks document support ,if you are in trouble,its hard to find help.For this reason,i gave up using torque.
[Jan 12, 2004 10:54:35 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Male chip33550336
Newbie




Joined: May 14, 2003
Post Count: 20
Status: Offline
Reply to this Post  Reply with Quote 
Re: http://db.apache.org/torque/

I found the documentation to be quite good. The only problem I had was setting up a Datasource in tomcat, and I ended up looking at the Tomcat documentation to get that running.

Besides that all the documentation I needed Torque provided. Although they may have updated it since you last looked at it.
[Jan 12, 2004 4:29:55 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male shardayyy
Member
Member's Avatar


Joined: Jul 2, 2003
Post Count: 74
Status: Offline
Reply to this Post  Reply with Quote 
Re: http://db.apache.org/torque/

Hmm nice to hear all these pros and cons..

:)
----------------------------------------
http://code.google.com/p/myalumni/
MyAlumni - is a Java/Jsp open source project that help keep alive the line of communications between alumni/alumnus of any school that are all over the world. Manage profiles, hide emails, hide address, PM etc...
[Jan 13, 2004 3:53:57 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest    http://www.naijatek.com    shardayyy    shardayyy [Link] Report threatening or abusive post: please login first  Go to top 
Male dejan
mvnForum Developer




Joined: Feb 27, 2003
Post Count: 185
Status: Offline
Reply to this Post  Reply with Quote 
Re: http://db.apache.org/torque/

Hmm nice to hear all these pros and cons..

:)


Here is one comparison of ORM tools which compares probably all known ORM tools ORM tools Comparison
[Jan 15, 2004 8:21:23 AM] Show Printable Version of Post    View Member Profile    Send Private Message    dejan_krsmanovic    76119246 [Link] Report threatening or abusive post: please login first  Go to top 
Show Printable Version of Thread  Post new Thread