Sanjay Jha

+ Follow
since Apr 05, 2015
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 Sanjay Jha

Hello All,

I have a question on @ElementCollection concept.

In pro jpa 2, if we are using ElementCollection, then the join table will have composite primary key that is if Elementcollection is basic type and assuming source entity has one primary key (for example pkid), then primary key in join table would be the 2 columns (pkid and basic var name in embedded class) and also same for embeddable element collection(pkid and all field of embeddables)

but when I am doing the same example using jpa-hibernate and MySQL server, the tables are showing pkid as primary key for both the cases, could anyone please clarify. thanks in advance.

Hello All,

Please see the following code..


then client as follows :-

After running the client the issue is that "BBS" and "KOL" values are not getting stored in CAPSTATES_KEY column and coming as null. Could anyone please let me know, why this is understanding. As per my understanding from pro jp2 book, it should get stored -page 117 listing 5.9
I am using jpa+Hibernate with MySQL.

Thanks & regards,
Hi Frits,

Thanks a lot for your clarification.. Happy with your answer .

Hello Everybody,

I am struggling to understand following code snippet unidirectional mapping..

public class Employee {

private int employeeId;
private Department dept;

In this case I understood deptid foreign key value is unique in employee table and wont be shared across rows. but I am able to persist 2 employee instance with same dept instance as follows : -

where e and e1 are employee class reference.


this code works absolutely fine and 2 records are getting inserted into employee table with deptid as 1. Could anyone explain please or if my understanding itself is wrong . I am using hibernate implementation of jpa and database in MySQL.Thanks in advance.

Kind Regards,

Hi Jeanne,

Thanks a lot for your reply, I am using hibernate, but is it possible hibernate is not implementing that portion of spec, I am not sure. please could you clarify..
and that's correct that I should not use public, I was just playing around because it was written that public is not allowed but it is still working....
Hello Everybody,

I have started preparing jpa cert and going through pro jpa 2 book.
While going through field access, it says about entity class "all filed must be declared as either protected, package or private.Public fields are disallowed"

But then I ran a sample application making the fields as public and I am able to persist the record. so confused, please can someone clarify.