Rodrigo Sasaki

+ Follow
since Mar 09, 2012
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 Rodrigo Sasaki

Hello everyone.

I am having a problem with JPA that I can't understand why. Here's the scenario.

I have my entity called RecipeVersion, that has a composite Id, that is composed by

recipeVersionId | recipeId | storeId

There is a business rule, that whenever a recipe version is already associated with a product, it cannot be altered, if the user tries to alter that version, a new version is persisted with his alterations, leaving the original one unchanged.

so when I get on this specific case, I make a copy of the object, so I don't have any problem with the references and add 1 to the value of the version by code.

if the PK is:

recipeVersionId = 1
recipeId = 32
storeId = 1

I search the database for the highest version of that recipe, and add 1, so in this case, if there is only that 1 recipe, the new PK looks like this:

recipeVersionId = 2
recipeId = 32
storeId = 1

But when I try to persist this new object, an EntityExistsException is thrown.

javax.persistence.EntityExistsException: a different object with the same identifier value was already associated with the session:

My Composite Id is mapped with @IdClass Annotation.

Does anybody have any ideas on what this might be?

Or any suggestions, I heared some people say this may happen because I try to control the recipeVersionId by code, is there any other way I could do it?

Please let me know if you need me to post some code or configuration, for a more clear view.


EDIT:PS: I have already tried detaching the object I create my copy from, using entityManager.detach but that still didn't work

EDIT 2: Here are the entities

Hello everyone,

I have just started working with EJBs, so I don't know much about them, but doing a test a faced the following situation:

I have an entity named Product, that has an N:N relationship with one called Sector

in other words a Product can be sold in many Sectors and a Sector sells many Products

In my Product entity I have a list of Sectors, in a @OneToMany relationship.

And in my database I have 3 tables: Products, Sectors, and ProductSectors.

All the data from this relationship is persisted in the ProductSectors table

Well then, on to the issue: I have a product with 3 sectors in it's list, all already persisted in the database, now when I remove one sector from my list, and merge my Product, I saw that hibernate executed 3 queries

So as you can see, all the records were deleted, and then he inserted the other 2 again, is this behavior normal? Is there any way for me to change it via configuration or something else? So it will just delete the one Sector, with a single query?

Thank you all in advance!
One of my attributes had a Composite Id that wasn't propperly set, after fixing that, I could persist with no problems.

Thanks anyway :
Hello everyone, I'm trying to persist an object with many dependencies with it, and with different types of relationship, @OneToMany, @ManyToOne, etc. It's a big DTO.

But I get this exception on persisting.

A NullPointerException é lançada dentro do método do Hibernate, alguém ja se deparou com esse problema e/ou sabe como resolver?
As you can see the Exception is thrown inside Hibernate's method, has anyone seen this problem before and/or know how to solve it?

On the DAO I use persist() on my DTO using my EntityManager, just like I do everywhere else in the system, so it wouldn't be a configuration problem, I believe.
I have tried using getReference() and find() on the dependencies before persisting, but still got the same Exception.

Any ideas? Thank you all in advance!

Please let me know if there is any additional information you may need.
I don't know exactly what it was, but it was a problem with the Primefaces 3 jar.

we switched back to primefaces-2.2.1 and it worked.

9 years ago
I think this is more of a JBoss Topic than a JSF one.

I opened the "%JBOSS_HOME%\standalone\deployments" folder and my deployment was there, the folders (package structure) was all there...

but not the .class files.. anybody know why?

9 years ago

I have the following problem:

I have this faces-config.xml file:

and I get a ClassNotFoundException on the UserPhaseListener class when I start my server.

the class is infact there.. here's the package and class name:

I'm running on JBoss AS 7.1.1 (Brontes), but this used to work today hehehe.. don't know what has happened here, perhaps I'm missing some configuration.

Any ideas?

9 years ago
Oh.. I see what you meant.. the Injection was just a suggestion for better use of the technology..

but I tried the static way and it didn't work.. JBoss gave me these JNDI names:


but the ones with java:app

cause the following exception:

and the other ones give me the "freezing" error
9 years ago
Can't get it to work..

but then again.. why isn't my lookup working the same way it was before on GlassFish?

is it wrong to do a lookup like that on JBoss?
9 years ago
hey.. I tried using @Inject on my attribute, just adding the annotation like this:

and it didn't work, the attribute was null and I got this error:

I even made a qualifier to try to fix this but it didn't work, any ideas?

I'll keep looking into it, see what I can find
9 years ago
You can probably tell.. I'm "junior" at all this hehe..
Never done any work with EJB before, so I'm sorry if I say any stupid things..

the ear has the following structure:

any notes?
9 years ago
First.. sorry about the duplicate, I'm new at Javaranch.. it won't happend again.


I have a classe in my model package doing the lookup, so I guess you are right.

The actual problem is that it worked on GlassFish, and now that I'm using JBoss 7.1.0 it doesn't work anymore.

Any idea what it might be?
9 years ago
actually no.. all I did was creating the new module, with all the dependencies that it required..

and adding the reference to it as my jpaProvider on my persistence.xml

I didn't really change the MANIFEST.MF, don't know if that actually makes a difference..

but it looks like you're having trouble with different jar files aren't you? not the hibernate config
9 years ago

I checked it and the JNDI lookup name is exactly how I was using it..


that's what I don't understand, I try the lookup and it just freezes, don't know if I'm missing configurations on JBoss or on the EJB
9 years ago
I don't know if this post should be here or on JBoss Forums. but here I go

I'm trying to do an EJB lookup on JBoss 7.1.0 like this:

which works fine on GlassFish, but didn't work on JBoss... when I get to the lookup line it just "freezes" waiting for a response I imagine, and the deployment times out..

then I read this thread, explaining how to do it.. then I tried it like this

and still.. same problem..

don't know how to fix this, has anybody had a problem like this here?

here is the EJB classes.. in case there is anything relevant there

and the implementation

the ejb.module is in a .jar inside my ear

9 years ago