I compared several java code generators, such as sql2java, torque, mdaog.sf.net, firestorm @ www.codefutures.com.
I found some approaches are good:
1. separate the generated code and editable file.
In this way, if there is any change on the schema, my override codes are in another file. Don't need to merge the code, but override the file.
2. Composite Primary key can be handled:
Currently sql2java can handle single field primary key?
sample code from Firstorm/DAO (not open source)
CustomerDao dao = CustomerDaoFactory.create();
Customer customer = new Customer();
customer.setId( null );
customer.setName( "Andy" );
CustomerPk pk = dao.insert( customer);
3. output structure/pattern is easy to understand.
DAO
DTO
Exception
Factory
...
Just for reference.
You are doing very well too.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
sql2java is good now
but if the generated code look like Firestorm/DAO does, it will be great!
http://www.codefutures.com/products/firestorm/faq/jdbc/transactions.html
Hello,
Take a look at our example program that uses our generated code:
http://sql2java.sourceforge.net/xref/sql2java/sample/SampleMain.html
The way we handle transaction seems simpler than what you suggest. Please explain how we could
improve it.
Thanks for your feedback
Nicolas.
Hi Nicolas,
I compared several java code generators, such as sql2java, torque, mdaog.sf.net, firestorm @ www.codefutures.com.
I found some approaches are good:
1. separate the generated code and editable file.
In this way, if there is any change on the schema, my override codes are in another file. Don't need to merge the code, but override the file.
2. Composite Primary key can be handled:
Currently sql2java can handle single field primary key?
sample code from Firstorm/DAO (not open source)
CustomerDao dao = CustomerDaoFactory.create();
Customer customer = new Customer();
customer.setId( null );
customer.setName( "Andy" );
CustomerPk pk = dao.insert( customer);
3. output structure/pattern is easy to understand.
DAO
DTO
Exception
Factory
...
Just for reference.
You are doing very well too.
public interface CustomerDAO
{
public void insert(Customer customer)
throws CustomerDAOException;
public void update(CustomerPK pk, Customer customer)
throws CustomerDAOException;
public void delete(CustomerPK pk)
throws CustomerDAOException;
public Customer[] findAll()
throws CustomerDAOException;
public Customer findByPrimaryKey(String email)
throws CustomerDAOException;
public Customer[] findByCompany(int companyId)
throws CustomerDAOException;
}