After all these years your videos are the best way to understand JPA relations. Thanks for share your knowledge.
@areebwadood6273
2 жыл бұрын
JPA annotations to be precise i guess !!!
@akshatghai2105
8 жыл бұрын
Amazing, Thanks for the tutorials. Keep up the good work.
@588kumar
7 жыл бұрын
Nice Tutorial on Hibernate Mapping. Easy to understand.!
@iampasindu
7 жыл бұрын
Cool lesson. Thanks!
@akularamesh9554
11 жыл бұрын
well explained all the concepts.
@t5a55i
11 жыл бұрын
I haven't worked with Hibernate for some years now, so I wanted to refresh on it, since I am readin a lot at the moment I did not want to recap on a book so came across this tutorial trail. This is really well done, thanks a lot, enough detail, good example, thanks a lot!
@roamingdev
9 жыл бұрын
Hello and thanks for the amazing tutorials! I have one question regarding the data types in the relationship. You use the Collection interface in the UserDetail class and the concrete implementation is an ArrayList. How would you access, for example, the first vehicle in the user's vehicle Collection? If you do user.getVehilcles() you get back a collection which has no get() method defined on it. Casting it to the concrete implementation also is not working (it throws a ClassCastException cannot cast PersistentBag to ArrayList) so the only way left is to use iterators which seems a bit too much to just get an item from the collection, especially if you need to get an item other than the first! Would using List as the interface be a better approach? Thank you very much once again! :)
@Java.Brains
9 жыл бұрын
George E. Kallergis Yes, you could use a List. the idea is to make sure you use an interface, not an actual implementation class. While that's generally considered best practice, it's especially vital when working with Hibernate because the framework gives you proxy classes. That's also why a class cast fails. What you were trying to convert is a proxy of an ArrayList.
@roamingdev
9 жыл бұрын
Java Brains I understand! Thank you very much for your response! :)
@metakiluku
12 жыл бұрын
I think this @ManyToOne creates additional field in vechile table. Can this be avoided?
@natetolbert3671
5 жыл бұрын
I don't like what hibernate is doing here. The three table approach is usually the solution for many-to-many relationship. In the case of multiple entities in a one-to-many relationship, why wouldn't it just generate a foreign key for the weak entity?
@958ice47dcube
10 жыл бұрын
No, because the table is created with a unique constraint on the vehicle id. It is a good practiice to put it in a join table like this, as business requirements may demand in the future that a many to many relationships be established. All that would need to be done is to drop the unique constraint on vehicle id, and make a composition unique constraint on both user id and vehicle id.
@natetolbert3671
5 жыл бұрын
That is a HORRIBLE practice. You can't just go around creating join tables for every one-to-many relationship in the database just in case...
@angelabensam8257
2 жыл бұрын
CAN YOU SHARE WITH US HOW DID YOU LEARN BASIC CONCEPTS . (uppercase used to get attention)
@ankushdapke3362
9 жыл бұрын
very nice sir thanks
@axis2038203
9 жыл бұрын
Are these tutorials still valid? Because all entities are auto created these days.
@borisjurosevic177
11 жыл бұрын
great like always
@VishalDeepVerma1
6 жыл бұрын
This is what I got: a column with the name "vehicle_id" will get added automatically in vehicle table, which represents user id....is this correct?? Please let me know if someone got same representation...
@recoveringheart
12 жыл бұрын
I get the following runtime error with this tutorial too. Could it be because I am using the latest version of Hibernate? Exception in thread "main" org.hibernate.exception.SQLGrammarException: Table 'hibernatedb.vehicle' doesn't exist
@sandeshbodake4605
6 жыл бұрын
Hibernate code changes by their versions..?..means if we write code in Hibernate3 will work on Hibernate4 or 5?
@despotjc3144
3 жыл бұрын
still worrking lol
@albalupa777
12 жыл бұрын
Why in postgreSQL vehicleID starts at 2, when in MySQL it starts at 1?
@wombstrat9116
11 жыл бұрын
I insist, when i do the reverse engineer of the database, that i'm using for this examples, the result diagram shows me a rare relationships, that not correspond to the usual database mapping, these diagrams tell me there is data redundancy.
@Das.Kleine.Krokodil
Жыл бұрын
Do I understand correctly that if there are two entities with a One-to-Many relationship, such as Employee and EmployeePhones. Then you need to receive such data on the server in DTO with one call, but with two separate json? And write down one by one: first the employee, get the ID from the saved employee, and then we record the phones using this ID for communication.
@rajeevbhosle1580
4 жыл бұрын
you are great....
@urseadinu
10 жыл бұрын
oh i saw u did that in the next tut :)
@SoeaOu
12 жыл бұрын
Thats a good question, do You know the answer by now?
@davehock7239
2 жыл бұрын
Hello, I am getting 3 vehicles in the database when I perform these steps, any ideas?
@sagarvyas9367
8 жыл бұрын
Hi, One thing I observe in Hibernate 5 is, when we do one to many it is not creating new table instead it will create column in other table like in this example it will create USER_ID column in Vehicle table , Is this something changed in hibernate 5? Thanks, Sagar Vyas
@wombstrat9116
11 жыл бұрын
Yep, you right; but you know how is this of hibernate XD!
@ismael88974
11 жыл бұрын
that column is probably showing up because you didnt delete the @JoinColumn annotation from the vehicle property
@bidya74
7 жыл бұрын
an exception occurs : An AnnotationConfiguration instance is required .please help me.
@dheereshcool8698
5 жыл бұрын
use AnnnotationConfiguration class inspite of Configuration..your problem will get resolved
@natetolbert3671
5 жыл бұрын
What version of hibernate are you using? Isn't the annotationConfiguration class deprecated in newer versions?
@amsfuy
11 жыл бұрын
By using a third table isn't this actually many-to-many?
@traderslearningbackyard2191
4 жыл бұрын
Third table doesn't mean many to many.
@jigarr6608
6 жыл бұрын
It will add a column in Vehicle tabel.
@VishalDeepVerma1
6 жыл бұрын
yes correct..thanks
@karamjitsinghsehdev3451
2 жыл бұрын
how to update files in (one to many) and vice versa
@ThierryBitz
3 жыл бұрын
@JsonIgnore @ManyToOne private Person person; To avoid an infinite recursion when working with a Rest-API Post Request (JSON).
@dcristea87
11 жыл бұрын
it's because of the sequence generator
@akhileshguptaakhi
11 жыл бұрын
the copy paste error lol, anyways nice
@KunalDawn
10 жыл бұрын
Good One.. Informative ... but too much redundent info...Please make it short.. dont repeat same thing again and again ..
@AdamTrojnar
9 жыл бұрын
Kunal Dawn omg how could you say that!, Kashik is great teacher :)
@axis2038203
9 жыл бұрын
Kunal Dawn Redundant is the subset of practice. You will learn only if you practice enough. So grow up boy!!
@gillianbc
8 жыл бұрын
+Kunal Dawn I disagree. It's only too much information if you know it all already. For someone like me who is learning, it's exactly the right level of explanation and I code along at the same time. He is a very good instructor.
@KunalDawn
8 жыл бұрын
gillian bc ***** TheBestONE EVer I agree with you.. but for me just the API capabilities information is enough.. so i can decide what to use based on my needs .. so redundant information was very annoying for me when i search quick overview..He is a good teacher. . but i have different needs... I am just too lazy to go through API docs when i need quick view... My comments were based on my needs.. and i expect the author should also upload contents for my type of audience... like currently it satisfies you guys.. And i can give my opinion to the author right? .. I have never offended any one here ..
@Simon18096
7 жыл бұрын
Using ManyToOne mapping, what does the following error code mean? Exception in thread "main" org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved beforeQuery current operation : org.myTwit.dto.Message.writer -> org.myTwit.dto.UserDetails This is my message class: package org.myTwit.dto; import javax.persistence.*; @Entity public class Message { public String content; public String messageDate; @ManyToOne public UserDetails writer; @Id @GeneratedValue public int MessageID; public UserDetails getWriter() { return writer; } public void setWriter(UserDetails writer) { this.writer = writer; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public int getMessageID() { return MessageID; } public void setMessageID(int messageID) { MessageID = messageID; } public String getMessageDate() { return messageDate; } public void setMessageDate(String messageDate) { this.messageDate = messageDate; } } Where is the mistake? I can solve it by saving the UserDetails object before retrieving the user that has written the message, the error appears as soon as i dont save the user.
@Simon18096
7 жыл бұрын
Here is my main method: public static void main(String[] args) { user.setMailAdress("linus.sparding@googlemail.com"); user.setNachname("Sparding"); user.setUserName("linuslovestennis"); user.setVorname("Linus"); myMess.setContent("Das hier ist schon meine zweite Nachricht"); myMess.setMessageDate(dateFormat.format(date)); myMess.setWriter(user); saveMessage(myMess); retrieveUserForMessage(myMess); } an the methods: public static UserDetails retrieveUserForMessage(Message message) { user=message.getWriter(); System.out.println("Die Nachricht '"+message.getContent()+ "' wurde verfasst von: "+user.getVorname()+" "+user.getNachname()); return user; } public static void saveMessage(Message myMess) { session.beginTransaction(); session.save(myMess); session.getTransaction().commit(); } public static void saveUser(UserDetails user) { session.beginTransaction(); session.save(user); session.getTransaction().commit(); }
@sajidalikhan5872
7 жыл бұрын
In your service class where your are saving the objects I think you have forgot to save in any persist object. So just cross check are you saving each and every persist object before closing session.
@sajidalikhan5872
7 жыл бұрын
and also check update should be update not create
@Sanjay54251
7 жыл бұрын
Every thing is correct but is I want add more user to one vehicle I would fail example if I added two user for one can now I want to update record for same car how can I do it please help. Me
@pr_squared
7 жыл бұрын
As the title would suggest, this annotation is for One to Many relationships. One user can have multiple vehicles associated with him, but one vehicle can only have a single user associated with him. What you're looking for, is the @ManyToMany annotation.
@Sanjay54251
7 жыл бұрын
how to add more data in onetomany hibernate without erasing previous data
@osamaasif9601
7 жыл бұрын
Change the create to update
@Sanjay54251
7 жыл бұрын
thankx buddy but i got my answer and but this is not my answer i answer is SQLQuery thanks again god bless you
@mavrav1
8 жыл бұрын
The visibility of the video is so low... Not even able to identify what is written 😑
@deepaksethy8502
7 жыл бұрын
poor explanation of relationship mapping
@electrontracker9914
7 жыл бұрын
Why do you think that explanation is poor?
@pr_squared
7 жыл бұрын
I wouldn't say it is poor explanation since the tutorial does serve it's purpose. But I would agree that it is a poor example of how one would do this in real life. You don't need to create a join table to map two entities. You can use the primary key of the user table as the join column for the vehicle table
Пікірлер: 65