Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!

Alex Pato

+ Follow
since Nov 08, 2011
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alex Pato

Ok, I'm in a bit of a mess right now. I have a Postgres 8.4 DB, 250 tables + stored procedures, triggers, etc. Stored procedures are mainly for the large transactions, as I plan to build the rest of the business logic via session and message-driven beans. I have built EJB Projects before on Netbeans, but as I planned to use WindowBuilder to develop the front end (GWT and Swing), switched to Eclipse. I hit a massive problem on the first hurdle ... generating my Entity Beans from the database. A more detailed explanation can be found here:

Basically, not all tables were being generated, and I was getting some association errors. The generator (Dali, as I've now come to know) seems to have a bug ... though I'm not too sure about it.

So, as a last resort, I decided to give Netbeans a shot. Everything seemed to be working well until I added a simple Session Bean for a user login (calling a stored function only because of data encryption) and get this error when deploying the project. I should note that the error is raised only when I add the EntityManager:

EntityManager em;

This is the error raised by Netbeans:

And this is raised by glassfish 3.1.1:

This is my Session Bean:

Please, any help would be more than welcome. At this rate, I'm planning to just dump EJB and go for a direct connection to my DB. I've been stuck at this first hurdle for a week now. So any help would be greatly appreciated.

Thanks Anthony. I've decided to use EJB3, with a few Postgres stored procedure calls when there are quite a bit of updates required. Hopefully it will do the trick. If not, I'll just use EJB to update all these tables and do away with the stored procedures altogether. I already have a few triggers, so I hope that improves the performance of my system.
Hi Jimmy,

Thanks for responding. Really appreciate your help.

I'm a little confused over your mentioning C3P0. I browsed through it and I don't get a clear cut picture. Are you suggesting that I use it in place of JPA (EclipseLink) and EJB Entity Beans? I'm currently intending to use the Postgres Connection Pool I created in the glassfish admin console with Entity Beans. As you stated, the efficiency of the system doesn't depend on the technologies I use but how well I implement my business logic. So I'm thinking there's another reason why you suggested C3P0 which I didn't quite catch. Could you kindly elaborate?

Now that I'm able to call Postgres Stored procedures from Session Beans, plus do simpler transactions via Entity Beans, I think that I'm just about ready to dig into my business logic. I'm going to try a simple example with BIRT, mainly testing the "drill down" facility to see if it works.

Thanks again for your responses.

Well, I was able to call a simple stored procedure in a Session Bean using the createNativeQuery() method of the Entity Manager. I'm sure it will become quite tricky when dealing with reports (getting the result sets), so I'm going to try working on a more difficult test.

This doesn't mean that I've decided to use these technologies, I'm still waiting on your feedback with regards to EJB's efficiency when dealing with large data sources + the benefits it brings ... whether my thinking was right or not.

Also, after some research on Java-base report building technologies, I've singled out BIRT (Eclipse) and Jasper Reports. I mainly need the 'drill down' capability intact. Also noted Business intelligence (Mozilla Public License). I can only use Open-Source software.

So are you saying EJB technology is not an efficient way to access large databases? Of course, there are many other simpler CRUD operations that I would like to implement using EJB Session and Entity Beans ... I was under the impression its a much more robust and secure way to go about accessing a database, as opposed to a 'simple' JDBC connection, which would be more prone to error and/or security leaks, with the database connection strings being in the source code of the application. I could use the Singleton pattern to connect to the database, but I just thought EJB was much more stable and secure. By letting glassfish handle the connection, and disabling its admin console on the server, I was under the impression that it was the most secure way to execute all database transactions.

Which is why I thought of using EJB's or rather glassfish's connectivity with the database to execute my stored procedures. This way I would have the advantages of both the security and easier manageability of EJB, with the added performance of stored procedures when I would require them.

Finally, with regards to Java Report Builders, which one would you recommend?

Thanks a lot for your input. I've been unsure of which Java-based technology I should use to implement my application. Basically security and performance are the main functional requirements I should base my decision on. I've already built the database in Postgres, so aside from that, nothing else has been established/decided yet. I intend to 'encapsulate' my business logic with a Web Service layer, so that different front-end applications can access the back-end.

Best regards.

Jimmy Clark wrote:

I'd like to know whether it is possible to call a Postgres Stored Function (PLPGSQL) from within my EJB Session Bean. I've been searching for a clear example, but haven't come a clear cut example.

Instead of "searching the Internet" for an example, I'd suggest spending some time thinking about the task and working your own solution. Code statements or functionality for calling external systems would not be written in the EJB classes. This is not their intended use. Session EJB are intended to execute business/domain logic and should do this via Business Object. The Business Object contains business logic and uses a Data Access Object to execute data access logic. The connection to a external system such as a relational database happens via Data Access Object and the code statements for this are in the Data Access Object, not the Session EJB or the Business Object.

If you code business logic or data access object directly in EJB classes, then you are creating a dependency directly on the EJB API in general and a "specific version" of the API as well. This is a poor design with restricted ability to handle change over time.

Thanks for the reply.

I think I'm just confused because I'm developing my project on Eclipse. I developed one before on Netbeans, and it was rather clear what was an entity bean and session/message driven bean. Here, with JPAs and Client modules, I'm a little lost.

The reason why I want to use stored procedures is ... I have quite a large database to manage. 200+ tables. When a table is updates, many others are as well. I thought I would save on performance IF I could reduce the amount of times the application server would have to communicate with the database. I initially used triggers in my database, but since some tables relied on the auto_generated IDs created in 'parent' tables, triggers will not suffice. Which is why I was thinking of inserting data into my databases via stored procedures.

Secondly, I would need to build a few reports. This would involve many joins and what not in order to build the reports. I haven't yet decided which technology I'm going to use to build the reports, but I've read that stored procedures are almost essential when it comes to building large reports.

Am I making sense or not? If I am, then I'm thinking a stored procedure call would require some code in the Entity Beans as well a DAOs? If you had any recommendations for report building, please let me know.

Thanks again.
Hi all,

I'd like to know whether it is possible to call a Postgres Stored Function (PLPGSQL) from within my EJB Session Bean. I've been searching for a clear example, but haven't come a clear cut example.

Been trying with a StoredFunctionCall object, but don't know what I'm doing wrong. I'm yet to try the createNativeQuery method on the EntityManager ... thought that it was more for stored procedures.

Any feedback would be appreciated.
At the moment, no. In fact, I have just decided on what operating system I should use for my server. It may take time, but I wanted to know whether it was possible to develop reports, generated from a data source, that is triggered using a GWT application. Otherwise, I may just end up using Swing.

One more thing I wanted to ask ... and as I have very little to no experience with GWT, please bare with me. Regarding the performance of a production system, in comparison to a server that would just supply data via web services to swing applications on various user computers, how would you rate GWT? I know there will be more load on the server. The one I'm working on has a Pentium Dual Core E5800 processor with 4GB of RAM, which should be serving say a maximum of 40-50 users at a time. Which would you recommend from a performance perspective?

Best Regards.
8 years ago

I'm new to the boards, as well as GWT. I'm planning to build a Java EE application using EJB and Web Services with a GWT front end. My application needs to build reports from a data source, and was wondering if there are any report builders that work hand in hand with GWT. I see you have gone into it in detail, but I just need to know if this is possible before deciding to start learning GWT.

I looked at it briefly and had difficulty going from one page to another, basically needing to crowd all my controls on the default GWT home page, if I may. So that is where I am at with regards to GWT.

So kindly let me know if this is possible before I start learning GWT as I have a short deadline to meet. If there are some frameworks such as smartGWT that can handle this, please let me know as well. Surprisingly, I have had much luck searching for information on Google.

Best regards.
8 years ago