Create Entity

  1. Select File > New > Entity in the menu.
  2. Under Entity > Name, enter the name Automaker.
  3. Click Finish.

Note:
  • Naming of entities - Typically, the names of entities are singular, e.g. Customer, while the names of database tables are plural, e.g. Customers.
  • Data Access Object - You can apply the settings under Data Access Object to create a Data Access Object (DAO) of the same name as the entity.
  • Persistence Unit - The Persistence Unit is automatically generated.
Parameter:
Result:
  • Project Management - Under Entities the Automaker class is created and under Data Access the AutomakerDAO class is created. 

    • Automaker

      @Entity
      @DAO(daoClass = AutomakerDAO.class)
      public class Automaker {
      
      	private int id;
      	public Automaker() {
      		super();
      		}
      
      	@Id
      	@GeneratedValue(strategy = GenerationType.AUTO)
      	public int getId() {
      		return id;
      	}
      
      	public void setId(int id) {
      		this.id = id;
      	}
      
      }
    • AutomakerDAO

      public class AutomakerDAO extends JPADAO<Automaker, Integer> {
      
      	public AutomakerDAO() {
      		super(Automaker.class);
      	}
      
      }
  • Entity-Editor - The new Automaker entity is displayed in the entity editor and can be edited.

Tips:

  • Attribute -  When adding attributes like name, the variable name, the Get method getName, and the Set method setName are generated in the entity class in which the name variable is accessed (getter and setter). The get and set methods are referred to as getters and setters.

    private String name;
    
    // Returns the attribute
    public String getName() {
    	return name;
    }
     
    // Sets the attribute
    public void setName(String attribute) {
    	this.name = attribute;
    }
  • Int or Integer - You are advised to use type classes such as integer for the attributes of your entities, since primitive data types like int can not assume a null value and such a value is frequently used in relational databases.
  • Missing Java data types - In the process of the database generation, the data types that are suitable for the database are automatically used for the Java data types used in the entities.
  • Source code changes detected - The entity editor allows you to work bidirectionally. The source code is automatically adjusted after each change you make in the entity editor. On the other hand, changes to the source code cause an automatic update in the Entity Editor. 

XDEV Software Corp. - One Embarcadero Center, San Francisco, CA 94111, US
Copyright © 2015. XDEV Software Corp. All rights reserved.