Logo

    hibernate

    Explore "hibernate" with insightful episodes like "Hibernate @ManyToMany Unidirectional and Bidirectional", "Hibernate @ManyToMany Unidirectional and Bidirectional", "Hibernate @ManyToMany Unidirectional and Bidirectional", "Hibernate @OneToOne Unidirectional / Bidirectional" and "Hibernate @OneToOne Unidirectional / Bidirectional" from podcasts like ""How to Program with Java Podcast", "How to Program with Java Podcast", "How to Program with Java Podcast", "How to Program with Java Podcast" and "How to Program with Java Podcast"" and more!

    Episodes (38)

    Hibernate @ManyToMany Unidirectional and Bidirectional

    Hibernate @ManyToMany Unidirectional and Bidirectional

    Hibernate @ManyToMany Unidirectional

    The Many-to-Many relationship can be best described by example.

    The example we’re going to use is that of the relationship between an Author and a Book.

    Authors publish Books, and Books have Authors. Any one Author can publish many Books, and any one Book can be published by many Authors, so this is why it is a many to many relationship.

    Other examples of the many to many relationship are Students to Courses and Employees to Projects.

    Let’s take a look at how the unidirectional many-to-many relationship is created using Hibernate... for more info please visit http://howtoprogramwithjava.com/session56

    Hibernate @ManyToMany Unidirectional and Bidirectional

    Hibernate @ManyToMany Unidirectional and Bidirectional

    Hibernate @ManyToMany Unidirectional

    The Many-to-Many relationship can be best described by example.

    The example we’re going to use is that of the relationship between an Author and a Book.

    Authors publish Books, and Books have Authors. Any one Author can publish many Books, and any one Book can be published by many Authors, so this is why it is a many to many relationship.

    Other examples of the many to many relationship are Students to Courses and Employees to Projects.

    Let’s take a look at how the unidirectional many-to-many relationship is created using Hibernate... for more info please visit http://howtoprogramwithjava.com/session56

    Hibernate @ManyToMany Unidirectional and Bidirectional

    Hibernate @ManyToMany Unidirectional and Bidirectional

    Hibernate @ManyToMany Unidirectional

    The Many-to-Many relationship can be best described by example.

    The example we’re going to use is that of the relationship between an Author and a Book.

    Authors publish Books, and Books have Authors. Any one Author can publish many Books, and any one Book can be published by many Authors, so this is why it is a many to many relationship.

    Other examples of the many to many relationship are Students to Courses and Employees to Projects.

    Let’s take a look at how the unidirectional many-to-many relationship is created using Hibernate... for more info please visit http://howtoprogramwithjava.com/session56

    Hibernate @OneToOne Unidirectional / Bidirectional

    Hibernate @OneToOne Unidirectional / Bidirectional

    One-to-One Unidirectional Relationship

    Since you’ve already learned about the ins and outs of how unidirectional one-to-many and bidirectional one-to-many relationships work, it’s time to learn about the One-to-One relationships.

    We will start things off with the unidirectional One-to-One relationship and how it’s set up in Hibernate.

    First thing is first, you need to understand how a One-to-One relationship is actually set up in a database. Once you understand that the child table declares the parent’s primary key as the child’s primary key, then we can get moving with the Hibernate stuff!

    For this example, we are going to use the One-to-One relationship between an Employee and their Address. TheAddress table will be set up as follows:

    For more information, please read the show notes via http://howtoprogramwithjava.com/session55

    Hibernate @OneToOne Unidirectional / Bidirectional

    Hibernate @OneToOne Unidirectional / Bidirectional

    One-to-One Unidirectional Relationship

    Since you’ve already learned about the ins and outs of how unidirectional one-to-many and bidirectional one-to-many relationships work, it’s time to learn about the One-to-One relationships.

    We will start things off with the unidirectional One-to-One relationship and how it’s set up in Hibernate.

    First thing is first, you need to understand how a One-to-One relationship is actually set up in a database. Once you understand that the child table declares the parent’s primary key as the child’s primary key, then we can get moving with the Hibernate stuff!

    For this example, we are going to use the One-to-One relationship between an Employee and their Address. TheAddress table will be set up as follows:

    For more information, please read the show notes via http://howtoprogramwithjava.com/session55

    Hibernate @OneToOne Unidirectional / Bidirectional

    Hibernate @OneToOne Unidirectional / Bidirectional

    One-to-One Unidirectional Relationship

    Since you’ve already learned about the ins and outs of how unidirectional one-to-many and bidirectional one-to-many relationships work, it’s time to learn about the One-to-One relationships.

    We will start things off with the unidirectional One-to-One relationship and how it’s set up in Hibernate.

    First thing is first, you need to understand how a One-to-One relationship is actually set up in a database. Once you understand that the child table declares the parent’s primary key as the child’s primary key, then we can get moving with the Hibernate stuff!

    For this example, we are going to use the One-to-One relationship between an Employee and their Address. TheAddress table will be set up as follows:

    For more information, please read the show notes via http://howtoprogramwithjava.com/session55

    Mapping Relationships with Hibernate

    Mapping Relationships with Hibernate

    In the past we have learned about database relationships, specifically the One-to-Many as well as the Many-to-Many and One-to-One and that was all good, great and grand…

    But now I want to talk about how to create those same relationships inside of Hibernate.

    Specifically, I want to focus on the One-to-Many relationship in Hibernate and how we go about mapping it out in our Java objects.

    But before we do, a word on unidirectional and bidirectional relationships.

    Unidirectional vs Bidirectional

    In Hibernate, it’s possible to map all three relationships that are available in a standard database, these include:

    • One-to-One
    • One-to-Many
    • Many-to-Many

    But what Hibernate also includes is the ability to make EACH of those relationships either unidirectional or bidirectional.

    This means that we can have a unidirectional One-to-One and a bidirectional One-to-One mapping, as well as a unidirectional One-to-Many and a bidirectional One-to-Many, as well as a unidirectional Many-to-Many and a bidirectional Many-to-Many relationship.

    That’s a lot of relationships!

    So what exactly are unidirectional and bidirectional relationships?

    Learn more on the show notes page via http://howtoprogramwithjava.com/session53

    Mapping Relationships with Hibernate

    Mapping Relationships with Hibernate

    In the past we have learned about database relationships, specifically the One-to-Many as well as the Many-to-Many and One-to-One and that was all good, great and grand…

    But now I want to talk about how to create those same relationships inside of Hibernate.

    Specifically, I want to focus on the One-to-Many relationship in Hibernate and how we go about mapping it out in our Java objects.

    But before we do, a word on unidirectional and bidirectional relationships.

    Unidirectional vs Bidirectional

    In Hibernate, it’s possible to map all three relationships that are available in a standard database, these include:

    • One-to-One
    • One-to-Many
    • Many-to-Many

    But what Hibernate also includes is the ability to make EACH of those relationships either unidirectional or bidirectional.

    This means that we can have a unidirectional One-to-One and a bidirectional One-to-One mapping, as well as a unidirectional One-to-Many and a bidirectional One-to-Many, as well as a unidirectional Many-to-Many and a bidirectional Many-to-Many relationship.

    That’s a lot of relationships!

    So what exactly are unidirectional and bidirectional relationships?

    Learn more on the show notes page via http://howtoprogramwithjava.com/session53

    Mapping Relationships with Hibernate

    Mapping Relationships with Hibernate

    In the past we have learned about database relationships, specifically the One-to-Many as well as the Many-to-Many and One-to-One and that was all good, great and grand…

    But now I want to talk about how to create those same relationships inside of Hibernate.

    Specifically, I want to focus on the One-to-Many relationship in Hibernate and how we go about mapping it out in our Java objects.

    But before we do, a word on unidirectional and bidirectional relationships.

    Unidirectional vs Bidirectional

    In Hibernate, it’s possible to map all three relationships that are available in a standard database, these include:

    • One-to-One
    • One-to-Many
    • Many-to-Many

    But what Hibernate also includes is the ability to make EACH of those relationships either unidirectional or bidirectional.

    This means that we can have a unidirectional One-to-One and a bidirectional One-to-One mapping, as well as a unidirectional One-to-Many and a bidirectional One-to-Many, as well as a unidirectional Many-to-Many and a bidirectional Many-to-Many relationship.

    That’s a lot of relationships!

    So what exactly are unidirectional and bidirectional relationships?

    Learn more on the show notes page via http://howtoprogramwithjava.com/session53

    Hibernate - Creating Data Access Objects (DAOs)

    Hibernate - Creating Data Access Objects (DAOs)

    Data Access Objects – What are they?

    Data Access Objects (or DAOs for short) are used as a direct line of connection and communication with our database. DAOs are used when the actual CRUD (CRUD = Create, Read, Update, Delete) operations are needed and invoked in our Java code. These data access objects also represent the “data layer” of our application.

    These objects are still just plain old Java objects that incorporate the use of some Hibernate annotations to give them the functionality we need from them. Again, that functionality being the communication with the database.

    Also, believe it or not, the concept of creating a file specifically for accessing the database is a design pattern. It’s called the Data Access Object Pattern and you can read more about it from this nice short Wiki article.

    What Hibernate Annotations Should We Use?

    Okay, so now that you’re somewhat familiar with DAOs, it’s time to learn how to integrate these plain old Java objects with our Hibernate framework (so they actually do the work we need them to do).

    There are two main annotations that you need to be familiar with:

    • @Repository
    • @Transactional

    To learn more, visit our show notes page via http://howtoprogramwithjava.com/session52

    Hibernate - Creating Data Access Objects (DAOs)

    Hibernate - Creating Data Access Objects (DAOs)

    Data Access Objects – What are they?

    Data Access Objects (or DAOs for short) are used as a direct line of connection and communication with our database. DAOs are used when the actual CRUD (CRUD = Create, Read, Update, Delete) operations are needed and invoked in our Java code. These data access objects also represent the “data layer” of our application.

    These objects are still just plain old Java objects that incorporate the use of some Hibernate annotations to give them the functionality we need from them. Again, that functionality being the communication with the database.

    Also, believe it or not, the concept of creating a file specifically for accessing the database is a design pattern. It’s called the Data Access Object Pattern and you can read more about it from this nice short Wiki article.

    What Hibernate Annotations Should We Use?

    Okay, so now that you’re somewhat familiar with DAOs, it’s time to learn how to integrate these plain old Java objects with our Hibernate framework (so they actually do the work we need them to do).

    There are two main annotations that you need to be familiar with:

    • @Repository
    • @Transactional

    To learn more, visit our show notes page via http://howtoprogramwithjava.com/session52

    Hibernate - Creating Data Access Objects (DAOs)

    Hibernate - Creating Data Access Objects (DAOs)

    Data Access Objects – What are they?

    Data Access Objects (or DAOs for short) are used as a direct line of connection and communication with our database. DAOs are used when the actual CRUD (CRUD = Create, Read, Update, Delete) operations are needed and invoked in our Java code. These data access objects also represent the “data layer” of our application.

    These objects are still just plain old Java objects that incorporate the use of some Hibernate annotations to give them the functionality we need from them. Again, that functionality being the communication with the database.

    Also, believe it or not, the concept of creating a file specifically for accessing the database is a design pattern. It’s called the Data Access Object Pattern and you can read more about it from this nice short Wiki article.

    What Hibernate Annotations Should We Use?

    Okay, so now that you’re somewhat familiar with DAOs, it’s time to learn how to integrate these plain old Java objects with our Hibernate framework (so they actually do the work we need them to do).

    There are two main annotations that you need to be familiar with:

    • @Repository
    • @Transactional

    To learn more, visit our show notes page via http://howtoprogramwithjava.com/session52

    Hibernate's most important annotation - @Entity

    Hibernate's most important annotation - @Entity

    What You’ll Learn

    The focus of this podcast / blog post is to teach you how to create the connection between your Java objects and the SQL Database tables. Remember, the whole point of the Hibernate framework is for you to be able to write Java code that allows you to communicate with your database.

    When I say that the goal is to communicate with your database, what I mean is:

    1. Create the tables (if they’re not already there) that will represent your Java objects
    2. Give Java the ability to send queries and execute scripts on your database
    3. Establish a transactional means by which to perform CRUD operations

    What we’re going to be tackling in this post will the step #1, how to get Hibernate to create our tables for us.

    Hibernate's most important annotation - @Entity

    Hibernate's most important annotation - @Entity

    What You’ll Learn

    The focus of this podcast / blog post is to teach you how to create the connection between your Java objects and the SQL Database tables. Remember, the whole point of the Hibernate framework is for you to be able to write Java code that allows you to communicate with your database.

    When I say that the goal is to communicate with your database, what I mean is:

    1. Create the tables (if they’re not already there) that will represent your Java objects
    2. Give Java the ability to send queries and execute scripts on your database
    3. Establish a transactional means by which to perform CRUD operations

    What we’re going to be tackling in this post will the step #1, how to get Hibernate to create our tables for us.

    Hibernate's most important annotation - @Entity

    Hibernate's most important annotation - @Entity

    What You’ll Learn

    The focus of this podcast / blog post is to teach you how to create the connection between your Java objects and the SQL Database tables. Remember, the whole point of the Hibernate framework is for you to be able to write Java code that allows you to communicate with your database.

    When I say that the goal is to communicate with your database, what I mean is:

    1. Create the tables (if they’re not already there) that will represent your Java objects
    2. Give Java the ability to send queries and execute scripts on your database
    3. Establish a transactional means by which to perform CRUD operations

    What we’re going to be tackling in this post will the step #1, how to get Hibernate to create our tables for us.

    Hibernate Persistence for Beginners

    Hibernate Persistence for Beginners

    What is a Persistence Framework?

    As the name implies, it has something to do with persisting things... this means that we're still talking about databases.  But what is it that we are persisting with this framework?

    Objects (of course)

    A persistence framework is something we use in Java to bridge the gap between Java and SQL.

    Hopefully we've gone through all of my previous tutorials and have learned a thing or two about Java and SQL.  But one thing I haven't taught you yet, is how to put your knowledge of SQL into Java.

    That's what I'll be teaching you throughout these Hibernate (persistence framework) tutorials.

    And if you haven't guessed it already, Hibernate is a persistence framework that you can use in Java.  It's what allows you to write Java code (staying true to Object Oriented programming practices) and yet still be able to communicate with your database.  Cool eh?

    For more information on this, check out the show notes page via: howtoprogramwithjava.com/session50

    Hibernate Persistence for Beginners

    Hibernate Persistence for Beginners

    What is a Persistence Framework?

    As the name implies, it has something to do with persisting things... this means that we're still talking about databases.  But what is it that we are persisting with this framework?

    Objects (of course)

    A persistence framework is something we use in Java to bridge the gap between Java and SQL.

    Hopefully we've gone through all of my previous tutorials and have learned a thing or two about Java and SQL.  But one thing I haven't taught you yet, is how to put your knowledge of SQL into Java.

    That's what I'll be teaching you throughout these Hibernate (persistence framework) tutorials.

    And if you haven't guessed it already, Hibernate is a persistence framework that you can use in Java.  It's what allows you to write Java code (staying true to Object Oriented programming practices) and yet still be able to communicate with your database.  Cool eh?

    For more information on this, check out the show notes page via: howtoprogramwithjava.com/session50

    Hibernate Persistence for Beginners

    Hibernate Persistence for Beginners

    What is a Persistence Framework?

    As the name implies, it has something to do with persisting things... this means that we're still talking about databases.  But what is it that we are persisting with this framework?

    Objects (of course)

    A persistence framework is something we use in Java to bridge the gap between Java and SQL.

    Hopefully we've gone through all of my previous tutorials and have learned a thing or two about Java and SQL.  But one thing I haven't taught you yet, is how to put your knowledge of SQL into Java.

    That's what I'll be teaching you throughout these Hibernate (persistence framework) tutorials.

    And if you haven't guessed it already, Hibernate is a persistence framework that you can use in Java.  It's what allows you to write Java code (staying true to Object Oriented programming practices) and yet still be able to communicate with your database.  Cool eh?

    For more information on this, check out the show notes page via: howtoprogramwithjava.com/session50