Monday May 01, 2006
The Best Feature Of The Upcoming NetBeans IDE 5.5 (Part 2)
After I blogged about the best feature of the upcoming NetBeans IDE 5.5, a couple of other bloggers sat up and took notice. Rightly so, because the work that has gone into integrating Java EE 5 development into NetBeans IDE for the upcoming 5.5 release is really compelling. Especially when combined with the state-of-the-art Glassfish server, of course. Two bloggers whose responses were particularly enthusiastic (yet enthusiastic in a down to earth, common sense kinda way) were Tim Bray and Philip Jacob Whirlycott.
However, somewhere in that blog entry, Tim wonders out loud: "Geertjan skips lightly over the database-selection wizard; I wonder how much more than "use these tables" it needs?" Well, here's the answer. In step 2 of that blog entry, after you choose the "Entity Classes from Database" menu item, the following dialog box appears:
All that happens here is that you set a database schema or a JNDI data source. And then all the tables available in the referenced database are displayed. At that stage you just select the tables in which you're interested and click Next. Nothing could be simpler and more logical than what has happened so far, right? In the next panel, the world is even more simple and logical:
Here you say what name you want the entity class representing the table to have. And you get default values. Then you're asked where you want the entity classes to appear. Finally, optionally, you set the persistence unit (which you also can do later, if you decide not to do it now):
Each entity class is just a POJO, so they all look like this (in other words, this is the result of going through the wizard, for one of the tables):
package org.me.pkg;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "DISCOUNT_CODE")
@NamedQueries( {@NamedQuery(name = "DiscountCode.findByDiscountCode", query = "SELECT d FROM DiscountCode d WHERE d.discountCode = :discountCode"), @NamedQuery(name = "DiscountCode.findByRate", query = "SELECT d FROM DiscountCode d WHERE d.rate = :rate")})
public class DiscountCode implements Serializable {
@Id
@Column(name = "DISCOUNT_CODE", nullable = false)
private String discountCode;
@Column(name = "RATE")
private BigDecimal rate;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "discountCode")
private java.util.Collection customer;
/** Creates a new instance of DiscountCode */
public DiscountCode() {
}
public DiscountCode(String discountCode) {
this.discountCode = discountCode;
}
public String getDiscountCode() {
return this.discountCode;
}
public void setDiscountCode(String discountCode) {
this.discountCode = discountCode;
}
public BigDecimal getRate() {
return this.rate;
}
public void setRate(BigDecimal rate) {
this.rate = rate;
}
public java.util.Collection getCustomer() {
return this.customer;
}
public void setCustomer(java.util.Collection customer) {
this.customer = customer;
}
public int hashCode() {
int hash = 0;
hash += (this.discountCode != null ? this.discountCode.hashCode() : 0);
return hash;
}
public boolean equals(Object object) {
if (object == null || !this.getClass().equals(object.getClass())) {
return false;
}
DiscountCode other = (DiscountCode)object;
if (this.discountCode != other.discountCode && (this.discountCode == null || !this.discountCode.equals(other.discountCode))) return false;
return true;
}
public String toString() {
//TODO change toString() implementation to return a better display name
return "" + this.discountCode;
}
}
Nice, neat code, right? Annotations instead of deployment descriptors. Java EE 5 is simplified J2EE 1.4. Glassfish is enhanced Sun Java System Application Server. NetBeans IDE 5.5, based purely on the evidence above, combines perfectly with them. Wonderful clean code generated according to the Java EE 5 specification and deployable via Glassfish.
May 01 2006, 08:56:00 AM PDT Permalink
Posted by Computerworld Blogs on May 02, 2006 at 11:53 AM PDT #
Posted by Rory on May 03, 2006 at 06:15 AM PDT #
Posted by Geertjan on May 03, 2006 at 06:24 AM PDT #
Posted by Rory on May 03, 2006 at 07:00 AM PDT #
Posted by Geertjan on May 03, 2006 at 07:07 AM PDT #
Posted by Rory on May 03, 2006 at 07:23 AM PDT #
Posted by Geertjan on May 03, 2006 at 05:00 PM PDT #
Posted by 192.127.94.7 on May 03, 2006 at 08:06 PM PDT #
Posted by 81.208.105.163 on May 05, 2006 at 04:28 AM PDT #
Posted by 12.171.224.124 on May 05, 2006 at 12:36 PM PDT #
Posted by david on May 05, 2006 at 01:53 PM PDT #
Posted by matt Verran on May 06, 2006 at 03:37 AM PDT #
Posted by Alessio Pace on May 07, 2006 at 01:46 AM PDT #
Posted by 213.205.199.234 on May 07, 2006 at 11:46 AM PDT #
Posted by Martin on May 07, 2006 at 04:16 PM PDT #
Posted by Geertjan on May 07, 2006 at 06:27 PM PDT #
Posted by Jap on May 08, 2006 at 12:10 AM PDT #
Posted by Seth on May 08, 2006 at 12:52 AM PDT #
Posted by anonc on May 08, 2006 at 06:53 AM PDT #
Posted by anonc on May 08, 2006 at 08:45 AM PDT #
Hi Seth, I don't know when this is planned to go live, but great to see so many are trying it out. Are you sure you have 1.5 source level selected as well as Java EE 5? (The latter during creation, the former afterwards in the Project Properties dialog box).
Posted by Geertjan on May 08, 2006 at 08:50 AM PDT #
Posted by Martin on May 08, 2006 at 08:54 AM PDT #
Posted by Maodo DIOP on November 22, 2006 at 06:58 AM PST #
Posted by Geertjan on November 22, 2006 at 07:12 AM PST #
Posted by Sarvesh Bhatnagar on July 06, 2007 at 03:12 AM PDT #
Posted by Geertjan on July 06, 2007 at 03:16 AM PDT #


