Adding, Editing, and Deleting Attributes

Adding attributes

  1. Click Add Attribute in the entity editor, and enter the name in name, e.g. company.
  2. Select the data type in Type, e.g. String.
  3. Click Save.
Note:
  • Attribute - When adding attributes like company, the variable company, the getCompany Get method as well as the setCompany Set method are generated in the entity class by which the company variable is accessed (getter and setter).

    private String company;
    
    // Returns the attribute
    public String getCompany() {
    	return company;
    }
     
    // Sets the attribute
    public void setCompany(String attribute) {
    	this.company = attribute;
    }
  • Int oder Integer - You are advised to use type classes such as integer for the attributes of your entities, since primitive data types like int cannot 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. 
Important properties:

Icon

Function

Change to Basic - This is the default setting of all attributes. Therefore, the @Basic annotation does not need to be explicitly set.

Change to Transient - Attributes labeled with @Transient are not persisted.

Change to Version - Labels the attribute with @Version. Version attributes are used for the optimistic locking of JPA.


  • Fetch type -  The fetch type defines whether the data of the attribute is loaded from the database immediately (eager) or when needed (lazy). Normally, this setting is important only for relations. Hibernate ignores this setting in normal attributes (@Basic) unless bytecode enhancement is enabled. Note that the re-loading process no longer works once the entity objects are detached.
  • Column name - Name of the database table.
  • Table name - Name of the database table that contains this column. If you specify an alternative table here, you will need to annotate the entity with @SecondaryTable.
  • Insertable -  If you set this value to false, the persistence provider (Hibernate) excludes this attribute when generating SQL insert statements.
  • Updateable - If you set this value to false, the persistence provider ignores this attribute in SQL update statements.
  • Unique - If you set this value to true, a unique constraint is generated when you create the database table for this attribute.
  • Nullable - If this value is set to false, this attribute cannot be null when saving or updating the entity. When creating the tables, a NOT NULL constraint is added for this column.
  • Length - The length of the column. This value applies only to string values.
  • Precision - Applies only for numbers with a fixed accuracy. Specifies the number of digits for this table column.
  • Scale - Applies only for numbers with a fixed accuracy. Specifies the number of decimal places.
  • Column definition -  The column definition is exactly the part of the SQL statement that describes this column. The SQL statement is generated when you create the tables. Using this column definition you can, for example, use a special (database) data type for this attribute.
  • Type mapping - Predefined annotations to customize the mapping between Java data types and data types in the database. The java.util.Date Java data type in an H2 database can, for example, be date, timestamp or time.

Fetch Type, Insertable, Updateable, and @Transient have no match in the database. These settings are relevant when inserting, updating, and retrieving data from the database.

All other settings are related to the structure of the database. Without export or update they have no effect.

Editing attributes

  1. Select the attribute you want to edit.
  2. Make the changes and confirm by clicking Enter. The source code is automatically generated and edited.
  3. Click Save.

Deleting attributes

  1. Select the attribute that you want to delete.
  2. Click Delete.
  3. In the following dialog, confirm by clicking OK.
  4. Click Yes in the following dialog to delete the getters and setters of the attribute, too. By default, they will not be deleted.
  5. Click Save.

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