users@glassfish.java.net

Re: Database view with JPA for jdbc realm

From: Felipe Gaúcho <fgaucho_at_gmail.com>
Date: Tue, 26 May 2009 09:17:44 +0200

AFAIK, unfortunately you need to run the script before to deploy the
application... :(



On Tue, May 26, 2009 at 9:11 AM, <glassfish_at_javadesktop.org> wrote:
> Hi,
>
> I have an application that uses form based security. The realm used is JDBC Realm. I have the entities User and Group for the JDBC realm. All database tables for the application are created when I deploy the application. For User and Group entities the tables users, groups and user_group is created. user_group is just a relation table to avoid redundancy by putting the username in the groups table.
>
> However, glassfish jdbc realm implementation requires username to be in the same table as the group name. To solve this it is usually suggested to use a database view, that selects usernames from users table and group names from groups table.
>
> But how can i get the container to create a database view, as it creates all the tables from the enteties? I tried the following:
>
> In a constructor of a servlet that is loaded at startup, I tried to call an injected (with @EJB) EJB. The EJB has access to an entity manager and executes an SQL create view statement. But, the problem is that in the servlet constructor the EJB instance is still null. I can call the EJB from the doGet method, and it works, but I would like the view to be created at deploy time automatically.
>
> My application is packaged in an EAR with one web module and two ejb modules.
>
> BR,
> Mattias
> [Message sent by forum member 'nightzero' (nightzero)]
>
> http://forums.java.net/jive/thread.jspa?messageID=347626
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>



-- 
Please help to test this application:
http://fgaucho.dyndns.org:8080/cejug-classifieds-richfaces