This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
after getting entity manager, we can call, find(), remove(), persist() etc methods to perform database operations.
but i have 3 doubts here:
1. what is java:comp/env here? where it is declared?
2. what is persistence/LogicalName here? where it is declared?
3. how it is knowing on which database i am performing this operations? (i mean to say, in jdbc we specify driver name, database name, username and password, here we are not specifying anything, how it is working?)
You are looking at sample code, so LogicalName is not what you called your persistence unit/entity manager. LogicalName is there as something that you replace with your specific data. The sample can;t guess what you are going to call it.
Your persistence.xml is missing a bunch of stuff, where do you put your database connection information?
Try reading the Toplink docs here for what you put into the persistence.xml and what everything means.
Means that there is an entity manager that is in JNDI under the "section" "persistence" with the name "LogicalName" in whoevers code that is. It is probably not the same name as your entity manager that is in JNDI.
Unless this is your code at your company, and if it is, then is that the correct persistence.xml, or is there another one, is there some other config file, or is there somewhere else in code that is binding that entity manager into jndi.
If you are using EJB3, also, you wouldn't even need that line of code, you could have the container inject the EntityManager in for you.