You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Jan T. Kim" <j....@uea.ac.uk> on 2010/06/10 18:38:10 UTC

CRUD for a set of persistent entities?

Dear List,

is there any technique / package / whatever to set up some basic CRUD
functionality for a group of persistent classes?

The idea I have is similar to that of a web based facility similar to
those GUI database browsers and editors.  In principle this this could
be realised using reflection and the persistence API's annotations.
Ideally, only one action should be needed and the system would generate
the web view and figure out the form data to support at runtime.

Any hints / thoughts?
-- 
 +- Jan T. Kim -------------------------------------------------------+
 |             email: j.kim@uea.ac.uk                                 |
 |             WWW:   http://www.cmp.uea.ac.uk/people/jtk             |
 *-----=<  hierarchical systems are for files, not for humans  >=-----*

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


Re: CRUD for a set of persistent entities?

Posted by "Jan T. Kim" <j....@uea.ac.uk>.
On Thu, Jun 10, 2010 at 07:47:13PM +0100, Ken wrote:
> On Thu, 2010-06-10 at 17:38 +0100, Jan T. Kim wrote:
> 
> > Dear List,
> > 
> > is there any technique / package / whatever to set up some basic CRUD
> > functionality for a group of persistent classes?
> > 
> > The idea I have is similar to that of a web based facility similar to
> > those GUI database browsers and editors.  In principle this this could
> > be realised using reflection and the persistence API's annotations.
> > Ideally, only one action should be needed and the system would generate
> > the web view and figure out the form data to support at runtime.
> > 
> > Any hints / thoughts?
> 
> I think what you ask for is very hard.  
> 
> You need to understand the database structure when setting up the
> system,
> because you need to know what to ask for...  So you're either going to 
> need to use SQL and manually do this or use an OR modelling tool and
> formalize these relationships.  

that formalisation is what the persistence annotations provide. Using
reflection you can find out whether an object is an entity, and what
its gettable properties are.

I've completed a CRUD browser which basically just iterates over these
getters, invokes each of them and produces a table of all gettable
properties such that

    * if the getter returns another entity, there's a link to the
      CRUD page displaying that entity,

    * if the getter returns a collection of entities, there's a list
      of links to the respective CRUD pages,

    * otherwise, just display the property using toString.

To support this CRUD action, I use a session which provides two methods:

    * findEntity, basically a facade to the entity manager's find method,

    * findEntityList, which uses EJB QL to get a list of all entities
      of that class

Thus far I've got only a browser (i.e. only the "R" out of "CRUD"), but
I'm quite sure that I'll be able to extend this to a more fully fledged
generic CRUD facility.

It's not intended for any serious production use but I think it will be
useful to give non-programming stakeholders early access to the entity
models.

Best regards, Jan

> Then there is no way to know what to present on a form, you would need
> to define this.
> A nice solution I have not seen (although like all good ideas may exist
> some place) is a hibernate/struts2 plug-in
> which works with hibernate tools to provide web based modelling of
> relationships and is able to generate both
> java beans which model the table (tools though the IDE already exist to
> do this) but also struts2 action beans.
> 
> It's easy to say this last part but doing it would be hard... The
> application might want the result set in certain data structures.
> HQL can handle this to a degree as it will convert the DB types to Java
> types in much the same way as OGNL, you can
> even ask for the data to be returned in a Map or List if appropriate.
> Or even a composite data structure of Maps and Lists.
> 
> To do this visually with any degree of ease I think HQL and the criteria
> API will need to to have full feature parity,
> as I could partially imagine an awesome visual DB query tool built on
> such a criteria API.
> 
> Okay so up to here we've needed to address DB modelling, Data
> Representation in the application, and address 
> what exactly is going to be on the report, then there would need to be
> layout of the report it self.
> 
> If such a plug-in could access an IDE then it could use the Hibernate
> tools plug-ins... then it could generate beans for tables and 
> compile and re-deploy.  This would be a good start and provide a very
> attractive model... that being web based build tools 
> specific to their application domain (IDE's turned inside out, being
> viewed as service providers).  A web based build tool entirely dedicated
> to struts2 aught to provide a more intuitive experience than a mere IDE
> plug-in.  Further I think that having to learn the UI elements,
> in a particular environment to be a big pain, where such a project would
> put the UI elements in the web domain making the whole project
> more assessable. So for this project to make sense we'd need the major
> IDE's to follow some sort of standardization effort... 
> 
> I think we all want a simple answer to Web-CRUD.  For it to be easy
> there are a lot of things that need to be addressed first.
> Many of them neither technologically nor socially trivial but I for one
> am very happy to see any progress in any of these areas.
> 

-- 
 +- Jan T. Kim -------------------------------------------------------+
 |             email: j.kim@uea.ac.uk                                 |
 |             WWW:   http://www.cmp.uea.ac.uk/people/jtk             |
 *-----=<  hierarchical systems are for files, not for humans  >=-----*

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


Re: CRUD for a set of persistent entities?

Posted by Cimballi <ci...@cimballi.net>.
It seems you are looking for a tool like Seam but for Struts2.
I don't know about any such tool but it should be possible to do the same.

Cimballi


On Thu, Jun 10, 2010 at 1:47 PM, Ken <ke...@aerose.com> wrote:
> On Thu, 2010-06-10 at 17:38 +0100, Jan T. Kim wrote:
>
>> Dear List,
>>
>> is there any technique / package / whatever to set up some basic CRUD
>> functionality for a group of persistent classes?
>>
>> The idea I have is similar to that of a web based facility similar to
>> those GUI database browsers and editors.  In principle this this could
>> be realised using reflection and the persistence API's annotations.
>> Ideally, only one action should be needed and the system would generate
>> the web view and figure out the form data to support at runtime.
>>
>> Any hints / thoughts?
>
> I think what you ask for is very hard.
>
> You need to understand the database structure when setting up the
> system,
> because you need to know what to ask for...  So you're either going to
> need to use SQL and manually do this or use an OR modelling tool and
> formalize these relationships.
>
> Then there is no way to know what to present on a form, you would need
> to define this.
> A nice solution I have not seen (although like all good ideas may exist
> some place) is a hibernate/struts2 plug-in
> which works with hibernate tools to provide web based modelling of
> relationships and is able to generate both
> java beans which model the table (tools though the IDE already exist to
> do this) but also struts2 action beans.
>
> It's easy to say this last part but doing it would be hard... The
> application might want the result set in certain data structures.
> HQL can handle this to a degree as it will convert the DB types to Java
> types in much the same way as OGNL, you can
> even ask for the data to be returned in a Map or List if appropriate.
> Or even a composite data structure of Maps and Lists.
>
> To do this visually with any degree of ease I think HQL and the criteria
> API will need to to have full feature parity,
> as I could partially imagine an awesome visual DB query tool built on
> such a criteria API.
>
> Okay so up to here we've needed to address DB modelling, Data
> Representation in the application, and address
> what exactly is going to be on the report, then there would need to be
> layout of the report it self.
>
> If such a plug-in could access an IDE then it could use the Hibernate
> tools plug-ins... then it could generate beans for tables and
> compile and re-deploy.  This would be a good start and provide a very
> attractive model... that being web based build tools
> specific to their application domain (IDE's turned inside out, being
> viewed as service providers).  A web based build tool entirely dedicated
> to struts2 aught to provide a more intuitive experience than a mere IDE
> plug-in.  Further I think that having to learn the UI elements,
> in a particular environment to be a big pain, where such a project would
> put the UI elements in the web domain making the whole project
> more assessable. So for this project to make sense we'd need the major
> IDE's to follow some sort of standardization effort...
>
> I think we all want a simple answer to Web-CRUD.  For it to be easy
> there are a lot of things that need to be addressed first.
> Many of them neither technologically nor socially trivial but I for one
> am very happy to see any progress in any of these areas.
>
>



-- 
Cimballi
JAVA J2EE Freelance
http://javajeeleader.elance.com/

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


Re: CRUD for a set of persistent entities?

Posted by Ken <ke...@aerose.com>.
On Thu, 2010-06-10 at 17:38 +0100, Jan T. Kim wrote:

> Dear List,
> 
> is there any technique / package / whatever to set up some basic CRUD
> functionality for a group of persistent classes?
> 
> The idea I have is similar to that of a web based facility similar to
> those GUI database browsers and editors.  In principle this this could
> be realised using reflection and the persistence API's annotations.
> Ideally, only one action should be needed and the system would generate
> the web view and figure out the form data to support at runtime.
> 
> Any hints / thoughts?

I think what you ask for is very hard.  

You need to understand the database structure when setting up the
system,
because you need to know what to ask for...  So you're either going to 
need to use SQL and manually do this or use an OR modelling tool and
formalize these relationships.  

Then there is no way to know what to present on a form, you would need
to define this.
A nice solution I have not seen (although like all good ideas may exist
some place) is a hibernate/struts2 plug-in
which works with hibernate tools to provide web based modelling of
relationships and is able to generate both
java beans which model the table (tools though the IDE already exist to
do this) but also struts2 action beans.

It's easy to say this last part but doing it would be hard... The
application might want the result set in certain data structures.
HQL can handle this to a degree as it will convert the DB types to Java
types in much the same way as OGNL, you can
even ask for the data to be returned in a Map or List if appropriate.
Or even a composite data structure of Maps and Lists.

To do this visually with any degree of ease I think HQL and the criteria
API will need to to have full feature parity,
as I could partially imagine an awesome visual DB query tool built on
such a criteria API.

Okay so up to here we've needed to address DB modelling, Data
Representation in the application, and address 
what exactly is going to be on the report, then there would need to be
layout of the report it self.

If such a plug-in could access an IDE then it could use the Hibernate
tools plug-ins... then it could generate beans for tables and 
compile and re-deploy.  This would be a good start and provide a very
attractive model... that being web based build tools 
specific to their application domain (IDE's turned inside out, being
viewed as service providers).  A web based build tool entirely dedicated
to struts2 aught to provide a more intuitive experience than a mere IDE
plug-in.  Further I think that having to learn the UI elements,
in a particular environment to be a big pain, where such a project would
put the UI elements in the web domain making the whole project
more assessable. So for this project to make sense we'd need the major
IDE's to follow some sort of standardization effort... 

I think we all want a simple answer to Web-CRUD.  For it to be easy
there are a lot of things that need to be addressed first.
Many of them neither technologically nor socially trivial but I for one
am very happy to see any progress in any of these areas.