HiberObjects

Download

Order

Forum

Vote for this plugin

The Result

We are ready and push Finish. A lot of new classes appear in the package:

Right-click on User and select Show in Class Diagram. Create a new class diagram and enter a name.

That's a big class! But it looks ok.

Now, where is the Java code? It's not generated yet. Save the class diagram to generate all the code. (You can also right-click on the HiberObjects icon and Save All.)

Let's have a look at the generated code:

This looks ok.

Generated Id

JPA can generate id values automatically when we insert new objects in the database. That can be accomplished with the @GeneratedValue annotation. In the phpBB3 database, all id columns use MySQL auto_increment, so @GeneratedValue will work. If it weren't for this, we might have to generate id's manually, which is a pain.

So, let's run the import wizard once more, modify the variableAnnotationsId method and push Update Method:

Push Finish, and then Save All on the HiberObjects icon or Save in a diagram.

The Java code now becomes:

/** * @generated */ @javax.persistence.Id @javax.persistence.Column(name="user_id", length=8, nullable=false) @javax.persistence.GeneratedValue(strategy=javax.persistence.GenerationType.AUTO) public int getId() { return this.id; }

This is what we want.

Next: Create DAO