Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Jennifer Debroone

Greenhorn
+ Follow
since Apr 28, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jennifer Debroone

Ximing Yu wrote:I'm working with a legacy database and have about 30 tables with same columns. There will be 13 million rows in total in the 30 tables. Is it possible to map a class to all 30 tables and have an attribute in class that map to different table name?

Using SQL to do query in any one table is already quite slow, so I doubt combining all 30 tables to one big table will result in unbearable low efficiency. Anyone have any idea about solving this kind of problem? Thanks.



Using a native SQL query shouldnt be any slower if you use UNION ALL

Ran Pleasant wrote:

Jennifer Debroone wrote:I want to get to the database through the database pool which is running on an application server. Can I use JNDI to do this from an application that does not run inside the application server? Or are the database pools only available for anything inside the application server? You know what I mean?


Question: If you are wanting to hit an application server in order to get to a DataSource (connection pool) then why not just build a data service (EJB) on the application server and call the service rather than trying to get a JDBC connection? I'm not saying you should not do as you are planning, just that you should have a very good reason.



ya, good idea, thanks for the answer !

Chris Lb wrote:For EJB 3 the entity objects are DTOs too, or should I say they are DTOs annotated as entity objects. The annotations mark the DTOs for special use in the context(s) where the @Entity is applicable.
So, yes, they are dual purpose. In the UI they are simply DTOs. Once they get inside of an EJB transaction, they are entity objects (i.e. entity beans, but not called that) that will map changes to the underlying persistence when attributes are changed for entity instances that are already managed. persist() and merge() can be used with the entity manager (i.e. in the biz tier) within your EJBs to make a DTO that is passed into a managed entity. (using "make" loosely here)
If you inspect a managed entity in the UI, you may notice that the lists for one-to-many relationships are handled differently than regular lists and the annotated DTOs carry additional properties for the @Entity annotation effect on the DTO.
Hope that answers your question



Thanks very much for that answer. So what they are doing is this: in their session bean for the method getAllUsers, the stateless bean returns a List<User> where User is annotated as @Entity.

I include the jar with the @Entity object on my side (presentation side), i invoke their remote session bean via jndi and call the getAllUsers method. Now I have a list of User marked with the @Entity object. I don't see any transformation of the entity object, it looks just like it did on their side.. the presentation side resides on a different machine than their facade.. on my side, I dont have any JPA libs loaded, (the interfaces exist but no jpa provider).. Im to use the @Entity objects as pojo's..

does that make sense? thanks again

J.
At work the guys wrote a DAO layer. I do the presentation side so I hook into their services with jndi lookups. They have a service called UserFascade for example and on that is a getNewUsers() function. When I call that, I get a List with the actual @Entity User {} objects back.

Is this the way its done? the actual Entity object is passed from the business method to the caller on the web side? Seems silly cause now I have access to the getPassword method ;) (although its hashed)

please advise on best practice?
I want to get to the database through the database pool which is running on an application server. Can I use JNDI to do this from an application that does not run inside the application server? Or are the database pools only available for anything inside the application server? You know what I mean?

Thanks,

J.