Uppala Ramana

Greenhorn
+ Follow
since Jan 14, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Uppala Ramana

i am refering to this line @OneToMany(mappedBy="item")
what us mean mappedBy="item" ?



Samanthi,

The mappedBy element identifies the inverse side of a relationship.

The inverse side of the bidirectional relationship (OneToOne,OneToMany,ManyToMany) refer to its owining side by using the mappedBy element.

In your example, mappedBy="item" is the inverse side of the relation that is Item-> Bids and Bid->Item is the Owning side.

To fetch Bid from object from the Item class, JPA uses the attribute or property specified in the mappedBy element.


Thanks,
Ramana.
Tan,

You have to use transactions...to sync your persistent entities to databse.

try{
entityManager.getTransaction().begin();
//persist
//merge
entityManager.getTransaction().commit();
}catch(Exception exception){
entityManager.getTransaction().rollback();
}

Thanks,
Ramana.

Caused by: java.lang.IllegalArgumentException: Object: SampleEntity.Customer@115441f is not a known entity type.



You have to declare your persistent classes in the persistent.xml like below:

<class>com.xxx.yyy.Employee</class>

Thanks,
Ramana.

The extended and transaction scoped are subtypes for the Container Managed Entity Manager. But what about Application Managed Entity Manager. Can't they also be transaction scoped or extended scoped? Correct me if I'm wrong



Hi Jothi,

There are two ways of using the EntityManager

1) Container Managed ::: Using Dependency Injection ...so the container is responsible for initializing the EntityManager
@PersistenceContext
EntityManager entityManager;

2) Application Managed::: User or Application is Responsible for creating and initializing the EntityManager

EntityManagerFactory emf = Persistence.createEntityManagerFactory("MyUnit")
EntityManager em = emf.createEntityManager();

Now coming back to Transaction or Extended ..those are the Persistence Context Types.
Container Managed Entity Manager can have any of the below Persistent Context Type

@PersistenceContext(type=PersistenceContextType.TRANSACTION)
EntityManager entityManager;


@PersistenceContext(type=PersistenceContextType.EXTENDED)
EntityManager em;

As far as i know, for the Application Managed Entity Manager ..application is responsible for managing the transactions.

But what about Application Managed Entity Manager. Can't they also be transaction scoped or extended scoped? Correct me if I'm wrong!



That dependes on the application code...i think there is no meaning of extended scope for the application managed entity manager.
Make sure java version of the client program is same as ejb deployed server java version.

Naming properties are need to be set to the context.

context = new InitialContext(properties);


Hi,
I am new to use JNDI. I want to know, that how do we bound our object to a particular 'name', and what do we mean by that. Also, if binding to a name and then looking up using the name to obtain a reference to this object, does this mean that I can access to any object running on any JVM on the internet? Or it means that looking up and obtaining the reference is only meant for the same JVM on which JBoss/any server providing the JNDI service is running.



We can bind the object to a name by using the InitialContext's bind API.
bind(name,object);

You can lookup the object by using lookup(name) and this returns you the object that mapped to the name.

I think lookup only works for the same JVM.
I think that is up to the Application Server Implementation ..unless you have custom class loaders in your EAR

That's what I thought. That's why I asked you to do a little bit of thinking yourself. So... what does it mean to make a class final? What effect does it have on the class?

Clearly that effect prevents the ORM software from working correctly, and that's why it's prohibited



Paul,

So, what the ORM software will do by creating a sub class of each Entity Bean ?
Is it will add some thing to each Entity ?

Paul,

I want to know the reason behind the statement "The Entity Class Must Not Be Final".

"The Entity Class Must Not Be Final".This statement is in EJB3.0 specification.

Why is that the entity class must not be final ?