Mon, 1 December 2014
Okay so you know how to add some styles and CSS to your webpage, that’s a great start, but what about deciding where all your text should go? What if you wanted to setup your website so that you have some text on the left hand side, and some images along the right? This is where design and layout comes into play. The |
Mon, 17 November 2014
Cascading Style Sheets are a bit of a tricky beast in HTML. Given this fact, I wanted to dedicate an entire section to just this topic. Let’s start with the basics, shall we? What are Cascading Style Sheets (CSS)? Well, we’ve already talked a little bit about HTML formatting tags (like Cascading Style Sheets actually exist as a completely separate file to your HTML code. |
Tue, 4 November 2014
In this HTML tutorial I would like to introduce two concepts to you:
The DOCTYPECurrently as of the date this was published, web browsers are (mostly) supporting HTML 5. HTML has gone through several versions and variations over it’s lifetime, and because of this it’s highly suggested that you include something called a DOCTYPE. The purpose of a DOCTYPE is to tell the web browsers what version of HTML you are using on any given webpage. The benefit of telling the web-browser what version of HTML you are using is that you save it from having to “guess”, which can often lead to strange behavior. |
Wed, 29 October 2014
I’m so ridiculously excited to be introducing a whole new aspect of programming. Over the next few months I will be posting new articles on the topics of HTML, Javascript and jQuery. These are all technologies that you can use to create your very own interactive website. The really cool thing about building websites, is that you can leverage your existing knowledge of Java to create ever MORE powerful websites. But let’s not get ahead of ourselves, for now we’ll focus first on HTML, then we’ll move into Javascript/jQuery. But enough big picture talk, let’s get into our introduction to html shall we?
An Introduction to HTML…HTML stands for HyperText Markup Language, and all this really means is that HTML is not a programming language, but rather just a set of rules for structuring your text. This means that if you type out certain words in a particular way, you can create a website! Piece of cake right? For the most part, YES, it is a piece of cake |
Mon, 20 October 2014
The presentation layer is one of the three main layers in object-oriented programming. The three main layers include:
Now, these three layers are typically related to enterprise web applications. It’s a design pattern used to help separate your code out in three distinct areas that (if need be) can easily be switched out with another programming language or technology. So if you keep all of your presentation layer code in one area of your application, switching presentation layer technologies shouldn’t be too difficult. Same rules apply to the business and data layers. If you separated your code out properly, switching databases shouldn’t be too big of an issue. Having said that, we’ll be focusing on the presentation layer. The four big players (in terms of technology) in the presentation layer are as follows: |
Fri, 10 October 2014
In our last Hibernate lesson, you learned how to fix duplicate data from hibernate queries. In this lesson we’re going to focus on some of theaggregate functions that can be used with Hibernate, and of course that means diving into the What’s important to note is that Hibernate doesn’t ever refer to it as So, armed with this knowledge, let’s jump into the lesson! Grouping Data with HibernateIn our examples, I’m going to show you how to create a query with hibernate that will group your data in some manner. When we build our query, we will be focusing on using Hibernate’s First, let’s start off with an example that we will build on. |
Mon, 15 September 2014
How to Fix Duplicate Data from Hibernate QueriesThis problem was the bane of my existence when I first started using Hibernate because I had no idea where the problem was coming from. If you’re executing a query and finding that you have a bunch of duplicate records and haven’t a clue why, then you’re in the right place. You see the problem is typically caused by having left joins (or optional joins) in your objects. When you have a base object, like say Consider this scenario… A So what happens when you run a query that joins to the So because of this, Hibernate doesn’t massage the data for you, it just returns exactly what it got from the database. The ball is in your court to tell Hibernate what to do with records it has retrieved. There are two solutions to this problem:
|
Fri, 5 September 2014
Now it’s time to dive into the nitty gritty of Hibernate’s mysterious inner workings. I’m by no means an expert in Hibernate, but I do use it almost every day for my own projects, so I do know a thing or two about how it works. One topic that had me scratching my head for ages was the Hibernate life cycle. What I mean by the life cycle is the way Hibernate interacts with Java objects at certain points in the existence of said Java objects. Let’s start from the beginning… What the heck is a Hibernate Life Cycle?You see, Hibernate is picky about your Java objects. Hibernate prefers your objects to be in a certain “state”, known as the persistent state… this persistent state is one of four different states that exist inside of the hibernate persistence life cycle. Once you have a firm grasp of the different states that an object can be in (as it pertains to Hibernate) you’ll be well on your way to mastering the Hibernate framework. So let’s get this Hibernate persistence life cycle lesson started shall we? Continue reading via: http://howtoprogramwithjava.com/session58 |
Wed, 27 August 2014
What the heck is a Fetch Type?Great question! Hibernate is a very handy framework for removing your need to fully understand SQL, but it will force you to understand things such as joins. Joining two tables in SQL is the foundation of a relational database, as joins allow you to actually define relationships between tables (objects). Having said that, relationships are important to understand when talking about fetch types in Hibernate. This is the case because whenever you define a relationship in Hibernate, you’ll also need to define the fetch type. The fetch type essentially decides whether or not to load all of the relationships of a particular object/table as soon as the object/table is initially fetched. For more information please see the show notes via http://howtoprogramwithjava.com/session57 |
Thu, 21 August 2014
Hibernate @ManyToMany UnidirectionalThe Many-to-Many relationship can be best described by example. The example we’re going to use is that of the relationship between an 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 |
Thu, 7 August 2014
One-to-One Unidirectional RelationshipSince 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 For more information, please read the show notes via http://howtoprogramwithjava.com/session55 |
Mon, 28 July 2014
Since we’ve already learned about the unidirectional @ManyToOne relationship, we can now move on to talking about what a bidirectional relationship is like, when using Hibernate. The term “bidirectional” literally means “functioning in two directions”, which is the concept that we will apply in our relationships between two Java objects. When we have a bidirectional relationship between objects, it means that we are able to access Object A from Object B, and Object B from Object A. We can apply this logic to our real world coding example that we saw in the last post. The example we will use is the relationship between an Employer and an Employee. Previously, we only defined a unidirectional relationship, so we could only access the Employer from the Employee object and not vice-versa. Now let’s take a look at how to transform our existing unidirectional relationship into a bidirectional one. |
Wed, 23 July 2014
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 BidirectionalIn Hibernate, it’s possible to map all three relationships that are available in a standard database, these include:
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 |
Tue, 15 July 2014
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:
To learn more, visit our show notes page via http://howtoprogramwithjava.com/session52 |
Tue, 8 July 2014
What You’ll LearnThe 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:
What we’re going to be tackling in this post will the step #1, how to get Hibernate to create our tables for us. |
Thu, 3 July 2014
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 |
Wed, 25 June 2014
The SQL Subquery So, what is a subquery? First and foremost, let’s get the jargon out of the way. A subquery can also be referred to as a nested query. It’s just like having a nested What’s very important to note here is that the SQL subquery can almost always be re-written as a More info on this via http://howtoprogramwithjava.com/session49 |
Mon, 16 June 2014
After having talked about all the SQL Aggregate functions, there’s one more topic that goes hand in hand with what we’ve already learned… The This particular keyword allows us to take a bunch of data and mash it all together into matching groups and then perform aggregate functions on those groups (like You might ask yourself why you’d want to “mash together” a bunch of data. The answer to this is best explained with an example, but let me try to put it in regular words before we jump into our example. Grouping data together allows us to look at aggregate data in relation to unique piece of data (or rows), a typical use case would be to group all the matching data together so you can get a count of the number of occurrences of specific data. An example related to grouping and counting could be a presidential election, you’ll have all the votes in a database and you’ll want to group that data together to get the total votes for each unique candidate... For more info, check out the show notes via http://howtoprogramwithjava.com/session48
|
Thu, 5 June 2014
In today’s podcast episode you’ll be learning all about the aggregate functions that exist in SQL. What the heck is an aggregate function? Well that’s what I’m going to try and teach you today, and I promise, it’s not a difficult concept to grasp. Just think of an aggregate function as a method that you’re calling that will process data in your database and return a value. Obviously the returned value will depend on which of the aggregate functions you choose to use. So that begs an obvious question, what are the aggregate functions that we can use in SQL? I’m glad you asked, here’s the ones that I use all the time in MySQL:
Okay, great! So now we know what the names of these functions are, now let’s see some examples of them in use! |
Wed, 28 May 2014
There are three categories of joins that you can make use of in SQL:
But before we dive into the categories of joins, we first need to have an understanding of what a join really is. Joins are used in SQL to bring together all the relevant data from multiple database tables. Remember that we've broken data down into multiple tables and established relationships between the tables.
... More via show notes: http://howtoprogramwithjava.com/session46 |
Fri, 23 May 2014
In this SQL tutorial episode/post we’re going to learn how to enforce our SQL relationships that we’ve already learned about. We’re going to be tackling the one-to-one and many-to-many relationships and we’re going to learn how to write the code to enforce these relationships in our database. As outlined in the podcast, we are going to be focusing on the many-to-many relationship with the
Show notes available via http://howtoprogramwithjava.com/session45 |
Wed, 14 May 2014
You’ve learned all about how to create sql queries to read, write, update and delete data… but you haven’t yet learned how to create the tables where you’ll be doing the reading, writing, updating and deleting. So that’s what today’s podcast is all about, be sure to click the play button above this to listen to the show and then follow along with the notes via http://howtoprogramwithjava.com/session44 |
Tue, 13 May 2014
Show Notes available via: http://howtoprogramwithjava.com/session43
In this post we will be expanding on the topic of database relationships and touch on two that are less common but just as useful. Many-to-Many RelationshipThe many-to-many database relationship is used when you are in the situation where the rows in the first table can map to multiple rows in the second table… and those rows in the second table can also map to multiple (different) rows in the first table.
One-to-One RelationshipA One-to-One relationship means that you have two tables that have a relationship, but that relationship only exists in such a way that any given row from Table A can have at most one matching row in Table B. |