Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » POJO generator from SQL query
POJO generator from SQL query [message #527725] Fri, 16 April 2010 09:08 Go to next message
Kuba P. is currently offline Kuba P.Friend
Messages: 9
Registered: February 2010
Junior Member
I'm looking for Eclipse plugin that creates for me POJO class from native SQL query e.g:
SELECT e.first_name,
 e.last_name,
 e.salary,
 d.department
 FROM emp e,
 dept d
 WHERE e.deptno = d.deptno


This plugin should generate class like this:
public class Employee{
 
 public Employee(){}
 
 private String firstName;
 private String lastName;
 private Number salary
 private String department;
 
 /* getters and setters here*/
}


I could use Hibernate tools but it generates only one POJO for one table, but I need to map more complex native queries.

If there is no that plugin is this very dificult to write my own ? How to start that. I mean following scenario:

1) From menu I could choose "Generate POJO from SQL query"
2) Then I could get a window with input areas to:
- paste SQL
- input pojo class name
- choose package
- choose connection from list defined in Database Developement perspective

Its all. Thanks for help
Kuba
Re: POJO generator from SQL query [message #527976 is a reply to message #527725] Sat, 17 April 2010 17:52 Go to previous messageGo to next message
Walter Harley is currently offline Walter HarleyFriend
Messages: 847
Registered: July 2009
Senior Member
"Kuba P." <jakub.pawlowski@zilp.lasy.gov.pl> wrote in message
news:hq99dj$6f2$1@build.eclipse.org...
> I'm looking for Eclipse plugin that creates for me POJO class from native
> SQL query e.g:
>
> SELECT e.first_name,
> e.last_name,
> e.salary,
> d.department
> FROM emp e,
> dept d
> WHERE e.deptno = d.deptno
>
>
> This plugin should generate class like this:
>
> public class Employee{
>
> public Employee(){}
>
> private String firstName;
> private String lastName;
> private Number salary
> private String department;
>
> /* getters and setters here*/
> }
>
>
> I could use Hibernate tools but it generates only one POJO for one table,
> but I need to map more complex native queries.

I would suggest working with Hibernate. It is able to do very complex
stuff, you just need to learn how. But it will be easier to learn Hibernate
than to write your own SQL parser, if your queries are that complex. Plus,
if you use Hibernate you will be able to take advantage of its other
features, such as caching.


>
> If there is no that plugin is this very dificult to write my own ? How to
> start that. I mean following scenario:
>
> 1) From menu I could choose "Generate POJO from SQL query"
> 2) Then I could get a window with input areas to:
> - paste SQL
> - input pojo class name
> - choose package
> - choose connection from list defined in Database Developement
> perspective
>
> Its all. Thanks for help
> Kuba
Re: POJO generator from SQL query [message #658789 is a reply to message #527725] Wed, 09 March 2011 18:56 Go to previous message
No real name is currently offline No real nameFriend
Messages: 1
Registered: March 2011
Junior Member
How about a web-based code generator that produces for you:

- DDL statement for your DB table
- JavaBean class to represent rows in the table
- Full-CRUD (Create/Read/Update/Delete) JDBC DAO class
- A full-CRUD, working web application (UI) with modern AJAX tachniques

Basically everything you need to implement a new feature that involves a new DB table. Better than Grails, and it's all pure Java, and totally free.

You're gonna love this, check it out here: http://www.timechannels.com/WhatIsPOJOJenerator

John
Previous Topic:temporary overlay window on Java editor
Next Topic:Can someone explain why this is not compiling?
Goto Forum:
  


Current Time: Thu Apr 25 10:44:24 GMT 2024

Powered by FUDForum. Page generated in 0.03266 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top