Skip to content

hayde/persistence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hayde.persistence.manager

i started to write this persistence manager, because other managers had quite difficult and complicated setting environments.

I resignated at a point, where i used hybernate and relized, that connecting to different databases for different 'hosts' (in that case it was a web-service with different agents, running on a single server), was going to drive me crazy.

Tested databases:

  • MySQL
  • PostgreSQL

usage

Class preperation

The classes require a 'annotation preperation' for the usage with the manager.

These preperations are seperated into the

  • header preperation: general definitions for that class and the table.
  • field perperation: informations about the single one variable, that should be joined with a column of a table

the header preperation

@Entity:

@Table:

@NamedQueries:

the field preperation

@Column:

  • name: (Optional) The name of the column ( in the table! ).
  • unique: (Optional) Whether the property is a unique key.
  • nullable(default true): (Optional) Whether the database column is nullable.
  • insertable(default true): (Optional) Whether the column is included in SQL INSERT statements generated by the persistence provider.
  • updatable(default true): (Optional) Whether the column is included in SQL UPDATE statements generated by the persistence provider.
  • columnDefinition: (Optional) The SQL fragment that is used when generating the DDL for the column.
  • table: (Optional) The name of the table that contains the column.
  • length(default 255): (Optional) The column length.
  • precision(default 0): (Optional) The precision for a decimal (exact numeric) column.
	@Column(name = "nodetype_name", unique=true, columnDefinition="varchar(30)", length=30)
	private String name;

@Basic: (optional = false)

@Basic( optional = false )
private String name;

@Id:

Id fields are (in general) used as primary key's for that table. This annotation is quite often used with the next one '@GenerateValue'.

Typically, this field is a 'long' in Java and 'bigint' in the database.

@GeneratedValue: (strategy = TABLE, SEQUENCE, IDENTITY, AUTO)

Id fields should be autogenerated by the database. The strategy is reliable for the type of the generating mechanism. 'AUTO' is the general setting for that field.

(actually i didn't test anything else yet!)

Example:

public class Node {
	public long id;
	public String name;
}
@Entity
@Table(name = "nodetype")
@NamedQueries({
    @NamedQuery(name = "NodeType.findAll", query = "SELECT * FROM nodetype")})

public class NodeType extends GenericEntityFunctions {

    @Id
    @Basic(optional = false)
    @Column(name = "nodetype_id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    public long id;
    @Column(name = "nodetype_name")
    public String name;

}

About

A simple, plain, SQL-Statement generating persistence Driver for Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages