File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Create bean with Init method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Create bean with Init method " Watch "Create bean with Init method " New topic
Author

Create bean with Init method

Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115
Hello,

Is there any plugin or tool for create POJO or bean with init() method ?
Not just POJO with getter, setter method. I need init method with default values.

Thanks
Kathiresan
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

How would the plugin know what the default values are?

Are you talking an IDE plugin, or a Spring plugin?
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

Can't you create a default constructor that sets default values?

Sean


I love this place!
Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115
Hello Guys,

I need to call like following in init() method

bean.setAddress1("");
bean.setAddress2("");
bean.setCity("");
bean.setState("");
bean.setZip("");

Also I have to create class which implements ParameterizedRowMapper
But I have around 50 columns to map like

car.setAddress1(rs.getString("ADDRESS1"));
car.setAddress2(rs.getString("ADDRESS2"));
car.setCity(rs.getString("CITY"));
car.setState(rs.getString("STATE"));

So am looking any external tool or eclipse plugin for generate this.

Thanks in advance
Kathiresan
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
Kathiresan Chinna wrote:
car.setAddress1(rs.getString("ADDRESS1"));
car.setAddress2(rs.getString("ADDRESS2"));
car.setCity(rs.getString("CITY"));
car.setState(rs.getString("STATE"));

I suggest to use a Data Mapper Framework like iBATIS.

Regarding code generation, you should try Code templates feature.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Create bean with Init method