The latest happenings at the Baltimore Washington Java Meetup

I just sent out an email to the illustrious members of my Java User Group (JUG), aka the Baltimore Washington Java Meetup.  The text is below.  All those interested in Java technology are invited and welcome!

Well well well!  What an AMAZING night we had for our November meetup!  I’ve been remiss to have not sent this sooner – things have been busy busy busy in Steve world – but you should know that November 10th was an amazing night.  We had about a billion people there – well, ok, perhaps it wasn’t a billion, but in all seriousness we maxed out the room – and it was all to hear the most excellent presentation by our very own rock star, Markus Dale, and his Overview of Amazon Web Services (AWS) and its Java API.  On hand were many illustrious members of our meetup, plus some additional celebrities, namely AWS’s Walt Whitecotton, John Peterson, and John Quarentello, who brought plenty of Amazon swag with them as giveaways and door prizes.

Speaking of the door prizes … the questions were:

1) Do you use (circle all that apply) (a) Ant, (b)Maven, (c)Jenkins, (d) Hudson?

Every answer was selected and there was a write-in or two for Gradle. But the hands-down leading choice was Maven.

This question was posed at JavaOne to a room of about 200 developers.  By a show of hands, about half used Jenkins, half Maven, and two people use Ant.

2) An annotation can be extended: (a) True (b) False

The correct answer is false! Now … should they be extendable?  Well that’s a different question altogether.  But in the meantime –

Congratulations to all the winners, especially Peter Stamboulis who won the 1st place price, a gift card for Amazon Web Services!

Most of all, a great big thank you and “bravo!” to Markus Dale, who clearly knows his stuff and did a fantastic edge-of-your-seat presentation on one of the hottest cutting-edge topics in the IT field today.

SO … our next meetup is … TONIGHT!  As we’ve been saying this fall, our December meetup would be non-standard, not a technical session, and that’s definitely the case this evening! We are simply meeting for dinner at a great restaurant in Columbia – pay your own way – click here for details.

In 2016 we’ll resume with technical sessions and already have a few in the works:  Lambdas, data streams, new features in Java 9, our own participation in the Adopt-A-JSR effort, and more!

But for tonight, we’re having a fun holiday dinner (pay your own way!), and everyone is invited!

See you tonight!

– Steve

Java, SQL, and the ORM Mismatch

I just can’t take it any more.

There is an incorrect perception floating around out there in Java world about the issue of mapping Java classes to SQL tables.  This issue falls within a larger topic often referred to as the object-relational mapping (ORM) mismatch.  This “mismatch” is based on the fact that Java is object-oriented, and SQL is not, so using Java classes to represent SQL tables involves some issues, and requires some clever work.  That is true.  But it’s led to a major misperception about SQL being supposedly “defective”.  It is not, but this notion has crept its way into two books I’ve read lately, books by otherwise very smart people, published by major cutting edge IT book publishers.

(For the record, no, neither publisher in question is my own publisher, the incomparable McGraw-Hill Education and their awesome imprint with Oracle Corporation, Oracle Press.)

I’m not going to verbally quote either work, but the idea goes like this:

  • To support persistence (storing data), you map a Java class (ex., “Customer”) to a corresponding SQL table (ex., “CUSTOMERS”)
  • When creating two Java classes, it’s possible to design them with a many-to-many relationship to each other
  • SQL doesn’t support the creation of tables with many-to-many relationships
  • Therefore SQL is defective.

Uh – no.

Folks, the presence of a many-to-many relationship in your data model is a sign that you aren’t finished with your data model.

This isn’t a Java thing, or a SQL thing, it’s a real world thing.

It’s possible to build a defective data model in Java.  You can do a lot of stupid stuff in Java.  You can also build bad data models in SQL, and technically you actually can create a many-to-many in SQL, but it won’t work.  That’s a good thing.  I’ll explain shortly with an example.

But first, a word about the classic mismatch.

THE ORM MISMATCH

The authors of these two books I’ve read are Java developers first and foremost.  I get that, and I know where they’re coming from.  I’m a Java developer myself, and have been since Java was first introduced into the Oracle database as an alternative to PL/SQL, which I also love – so much that my first book was the official Oracle Press certification exam guide OCP Developer PL/SQL Program Units Exam Guide.

But about the time that book hit the shelves, I began working with Java, which had become available as an in-database alternative to PL/SQL.  I soon thereafter began teaching Java.  In fact, this is me with then-CEO of Sun Microsystems, on the first day I launched my first ever course in Java:

Scott McNealy, Steve O'Hearn, at the National Press Club

That was taken at the National Press Club.  McNealy was hysterically funny that day and a great guy. He’s responsible for, and oversaw, a lot of great developments in Silicon valley that reverberate to this day – like Java.

And back at that time, the first question about Java was – how do we get Java and SQL to interact?  That, after all, was Oracle’s whole point of embedding Java in the database.

Java has come a long, long way since then, and all for the better.  There is a well established and growing library of packages and tools for implementing various interactions between Java and SQL.  And at the heart of them all is often the same issue:

Java is object oriented, and SQL isn’t.

True.  So what?  Newcomers to Java act like this is some kind of ultimate nightmare scenario, a sign that SQL is out of sync with the world.  Nonsense.  SQL isn’t inherently object-oriented, but neither is your file system.  And yet Java interacts with files just fine.  Now granted, the idea behind SQL is more sophisticated than file systems.  But on the other hand, SQL isn’t in the same category as a third-generation language (3GL) like Java, SQL is a fourth generation language (4GL). It might not support object-oriented dynamics, but neither does it clash with them.  This is demonstrably obvious – otherwise we wouldn’t have JDBC, the Java Persistence API (JPA), and Hibernate.  So the two can and do work together, and effectively.  But it takes a bit of work; SQL doesn’t necessarily provide built-in support for all object-oriented concepts, such as inheritance. (Caveat: Inheritance actually can be supported in data modeling – see this article – and there’s a way to do it within SQL itself, sort of, but as to whether it’s helpful or not, that’s a different story, and perhaps the topic of a future blog post.  Or book.  Hm …. )

Frankly, when I hear about the “mismatch” between Java and SQL, I think of the issue of transactions, that’s the only real issue to me. The object life cycle and nature of Java is such that it introduces challenges in the way persistence to the database is best done in a multi-user/multi-threaded environment.

But let’s get back to topic and dispel this “SQL is defective” myth.

DATA MODELING

Data modeling is the act of representing real world business processes through diagrams of the things (“entities”) that comprise a real world process, and the relationships (or “associations”) among those entities.  The most obvious entities are easy to identify – customers, products, office buildings, vendors, cars, etc.  But the more abstract entities are not always so obvious – work schedules, change orders, reservations, that sort of thing.  This is where the importance of understanding many-to-many relationships can be very helpful.

AN EXAMPLE

I’m going to use an example taken from the airline industry, as I’ve been meeting lately with Lisa Ray, a lifelong aviation data expert closely involved with a series of legacy migrations in that area. (And for the record, she fully gets this.)

Let’s start with two obvious entities:

  • Planes – as in “individual planes”, not just types of planes.
  • Pilots – individual people.

Every one plane might be flown by more than one pilot.  Every one pilot will be qualified to fly more than one plane.  Sounds like a many-to-many relationship, right?  And as you might know, an entity-relationship diagram illustrates the “many” side of a relationship with the classic crow’s-feet line:

ERD Diagram A

So that’s our initial logical diagram for these two entities.

Now folks, this blog post is not going to be a complete tutorial on how to perform data modeling, but we will explore one key aspect of modeling: whenever you encounter a many-to-many relationship, you ALWAYS transform it using the following steps:

  • Add a third entity in between – “Entity_3” in our diagram below.
  • Create foreign keys within the new entity for the primary keys of the existing entities – in this case, PLANE_ID as a foreign key to the PLANES entity’s PLANE_ID primary key, and PILOT_ID as a foreign key to the PILOTS entity’s PILOT_ID primary key.
  • Establish “one-to-many” relationships between the new entity and the existing entities, using the “single-line” to indicate the “1” side, and the “crow’s foot” to indicate “many” side of the relationship.

Like this:

ERD Diagram B

The reason we do that is simple:  the presence of a many-to-many relationship is a clear indicator that something else goes in between the two entities.  The question is not “if” something belongs there.  Something does belong there.  The only question is – what exactly is it?

In our example, it’s going to be something like a “roster”, or a “schedule”, or “flight assignments”, or “rentals”:

ERD Diagram C
Call it what you will, but something goes in between and it must be included in your data model.  That new entity will have its own attributes.  Perhaps:

  • A start and end date to the time of assignment
  • A name of a key staff member authorized to approve the assignment

Who knows what might be there? But something is there, and the presence of the many-to-many relationship is your clue to its existence.

That third entity is often a bit more abstract.  You can see pilots and planes, but a “flight assignment” isn’t necessarily as obvious.  But it’s an important entity in the data model nonetheless.

One more point:  this third entity isn’t some necessary crutch to get around a “SQL defect”. I can’t believe what I’ve read in certain Java books that suggest such a thing.  No.  This third entity is a real world “thing” that definitely exists in order to enable the relationship with the real world, and it’s up to you to identify it. Whether you figure it out or not, it exists nonetheless.

The rule is simple: no complete data model exists with any “many-to-many” relationships.  If such are present, you aren’t done modeling yet.

So now that you understand this, imagine reading a Java manual in which someone explains that SQL is “defective” because it “doesn’t support many-to-many relationships”.

No.

Now you know!

O’Hearn is the Java leader of the only officially recognized JUG for the DC metro area.  He is also the author of the first-ever expert-level certification exam guide from Oracle Press, titled OCA Oracle Database SQL Certified Expert Exam Guide (Exam 1Z0-047).  The 2nd edition of his SQL Expert book, revised for Oracle 12c, is due out in 2016.

Conference in Williamsburg, Sqoop, and Big Data Connectors

Yesterday  – April 24, 2014 – I had the privilege of presenting at the Virginia Oracle User Group (VOUG) annual Oracle Conference on the James, or OCOJ for short.  The “James” is the James River right there in Williamsburg, Virginia.  I promised my audience I would publish the Power Point slides, so here they are:

Yesterday could not have been a more glorious day. The Doubletree Hotel in Williamsburg is really a conference center, with a variety of beautiful meeting rooms and great skylights and large glass walls.  The room in which I presented was unusual in that it had one door that led directly outside.  The hotel propped it open and the beautiful air flowed it, it was remarkably refreshing.  I particularly enjoyed it, given the many snow days we’ve had this past winter and even into the spring.  The air was fresh and the temperatures just perfect, what a great day.

I was definitely in with some illustrious company – other presenters throughout the day included Mary Gable, David Mann, Craig Shallahammer, Greg Mays, Scott Poteet, Bill Myers, and Oracle’s own Bob Bunting as well as Robert Freeman.  The legendary Tom Kyte (of Ask Tom fame) was the keynote speaker.  Brilliant talent was on display everywhere.

For more information about VOUG, visit their website here:  http://www.voug.org.

Here’s a copy of the full conference agenda:  VOUG OCOJ Conference Agenda.

Thanks to one of my great audience members who took the photo.  And a huge thanks to Linda Hoover for making the entire event possible – thank you Linda!

Java: Critical Update Issued by Oracle Corporation

Oracle issued critical updates to Java on Tuesday, Reuters reports:

The patch fixes 42 vulnerabilities within Java, including “the vast majority” of those that have been rated as the most critical, said Oracle Executive Vice President Hasan Rizvi.

For more: http://news.yahoo.com/oracle-fixes-42-holes-java-revive-security-confidence-213431315–sector.html

DHS Warns About Java; Red October Connection?

A few days ago, the U.S. Department of Homeland Security issued a warning to temporarily disable Java on your computers, warning of:

A vulnerability in the way Java 7 restricts the permissions of Java applets could allow an attacker to execute arbitrary commands on a vulnerable system.

Now this morning we have this from ARS Technica: Red October relied on Java exploit to infect PCs

Attackers behind a massive espionage malware campaign that went undetected for five years relied in part on a vulnerability in the widely deployed Java software framework to ensnare their victims, a security researcher said.

And:

Oracle developers patched the bug in October, 2011, the malicious Java archive file was compiled the following February.

Be warned.

Oracle and Java – A Good Brew

Scott McNealy, Steve O'Hearn, February 8, 2001, National Press ClubI first met Scott McNealy on Thursday afternoon, February 8, 2001, at about 12:15 in the afternoon.  Not that I was keeping track or anything.  But I was starting to teach a new Java course that night, based on curriculum I’d created, so the timing was particularly striking to me personally.  McNealy was the CEO of Sun Microsystems, creator of Java. McNealy was the featured speaker at the National Press Club’s luncheon that day.  I’d brought a couple of professional colleagues and friends to meet him.

The Java programming language was already important to Oracle systems, which was why my company was launching the new course.  Our company, db-Training, already taught coursework in Oracle development and database administration.  We were very early to recognize the significance Java would have to the Oracle database.  There was a key architectural similarity between the two products that was rare among the various competing products of the time.  I’ll explain.

The Oracle Relational Database Management System (RDBMS) wasn’t – and isn’t – just a database.  It’s an operating platform.  This fact cannot be overstated, especially to those who haven’t worked with Oracle.  The RDBMS stores data and houses software snippets, in a container that can operate on any operating system.  So if you created a database application in the Oracle RDBMS – and I did, quite a few of them – you could do so without a concern for what operating system your application may end up running on.  The trick was that you just moved the application into a version of the RDBMS designed for that new operating system.

But if you created a database application in, for example, traditional COBOL or FORTRAN or something else, you had to concern yourself with the operating system in which you were going to execute the program.  Is it Microsoft Windows?  Which version? Is it Unix?  Or something else – an Apple computer of some sort?  For each new environment, you would have to recompile your FORTRAN or COBOL or whatever program, being aware that the compilation may result in errors, even if it had compiled perfectly well on another operating system already.

With Oracle, you didn’t have to bother with that nonsense.  Create your app in the Oracle database, and you’re done – it’ll work on any operating system, you just have to move the app to the appropriate RDBMS.

However – you couldn’t use FORTRAN (well, ok, you could, but just go with me on this, you Pro*Fortran people).  You had to use an Oracle proprietary language called PL/SQL.

I love PL/SQL.  I love it so much, I wrote a book about it.

Then along came Java, and its Java Virtual Machine.   I think Oracle Corp was quick to realize that the JVM was to Java what the Oracle RDBMS was to database applications – a buffer between the Java program and the operating system, which meant that you could write a single application in Java, and then move it from operating system to operating system by swapping your existing JVM with one that fit the new operating system.  You didn’t have to recompile or rewrite code.  You just had to do a one-time installation of the JVM at the new location, that’s it.

Just like the Oracle RDBMS.

When Oracle acquired Sun Microsystems, a lot of conspiracy theorists rolled their eyes and figured Oracle would destroy Java somehow.  I was pretty confident Oracle wouldn’t do that.  It made good business sense for them to support Java.

I was there at Oracle Open World when Scott McNealy spoke.  You could tell he was impacted powerfully by the acquisition of Sun by Oracle.  I don’t think it was his preference, but rather an economic necessity.  I’m sure he would’ve kept Sun independent if possible. But since he had to sell, Oracle was the best way to go.

And now – history has shown that Oracle has been very good to Java, according to InfoWorld.

I could’ve told you that years ago.  Oracle needs Java.  It was a good fit, and still is.