comze-orm

Comze ORM Framework

License

License

Categories

Categories

Net ORM Data
GroupId

GroupId

net.comze
ArtifactId

ArtifactId

comze-orm
Last Version

Last Version

3.3.2
Release Date

Release Date

Type

Type

jar
Description

Description

comze-orm
Comze ORM Framework
Project URL

Project URL

https://github.com/comze/comze-orm
Source Code Management

Source Code Management

https://github.com/comze/comze-orm

Download comze-orm

How to add to project

<!-- https://jarcasting.com/artifacts/net.comze/comze-orm/ -->
<dependency>
    <groupId>net.comze</groupId>
    <artifactId>comze-orm</artifactId>
    <version>3.3.2</version>
</dependency>
// https://jarcasting.com/artifacts/net.comze/comze-orm/
implementation 'net.comze:comze-orm:3.3.2'
// https://jarcasting.com/artifacts/net.comze/comze-orm/
implementation ("net.comze:comze-orm:3.3.2")
'net.comze:comze-orm:jar:3.3.2'
<dependency org="net.comze" name="comze-orm" rev="3.3.2">
  <artifact name="comze-orm" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.comze', module='comze-orm', version='3.3.2')
)
libraryDependencies += "net.comze" % "comze-orm" % "3.3.2"
[net.comze/comze-orm "3.3.2"]

Dependencies

compile (2)

Group / Artifact Type Version
com.mchange : c3p0 jar 0.9.5.2
commons-dbcp : commons-dbcp jar 1.4

Project Modules

There are no modules declared in this project.

Quick Start

Adding dependency

<dependency>
    <groupId>net.comze</groupId>
    <artifactId>comze-orm</artifactId>
    <version>3.3.2</version>
</dependency>

Sample Code

import net.comze.framework.orm.support.SqlMapDaoSupport;

public class SampleDao extends SqlMapDaoSupport {
	
	private static final String SAMPLE_SQL_SELECT = "select `id`, `username` from `sample` where `id` > ? limit 1;";
	
	public SampleEntity select(long id) {
		return getSqlMapTemplate().queryForObject(SAMPLE_SQL_SELECT, SampleEntity.class, id);
	}
	
}
import net.comze.framework.annotation.Attribute;

public class SampleEntity {

	private Long id;

	@Attribute(name = "username")
	private String name;
	
	// ... Aetter and setter

}
import javax.sql.DataSource;

import net.comze.framework.orm.datasource.DbcpDataSourceFactory;

public class Sample {

	public void sample(long id) {
		DataSource dataSource = new DbcpDataSourceFactory().getDataSource();  // load jdbc.properties
		SampleDao sampleDao = new SampleDao();
		sampleDao.setDataSource(dataSource);

		SampleEntity sampleEntity = sampleDao.select(id);
		// ...
	}

}

Use @PropertiesEditor annotation

import net.comze.framework.annotation.Attribute;
import net.comze.framework.annotation.PropertyEditor;

public class SampleEntity {

	private Long id;

	@Attribute(name = "username")
	private String name;
	
	@PropertyEditor(className = "sample.JsonAddressEditor")
	private Address address;
	
	// ... Aetter and setter

}
public class Address {

	private String state;

	private String city;

	private String street;

	// ... Getter and setter

}
import java.beans.PropertyEditorSupport;

import com.google.gson.Gson;

public class JsonAddressEditor extends PropertyEditorSupport {

	@Override
	public Object getValue() {
		return new Gson().fromJson(getAsText(), Address.class);
	}

}

Use @LowerCaseWithUnderscores annotation

@LowerCaseWithUnderscores
public class SampleEntity {

	// ...

}
public class SampleEntity {

	private String firstName;

	@LowerCaseWithUnderscores
	private String lastName;

	public String getFirstName() {
		return firstName;
	}

	@LowerCaseWithUnderscores
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	// ...

}

Use @CaseSensitive(false) annotation

@CaseSensitive(false)
public class SampleEntity {

	// ...

}
public class SampleEntity {

	private String firstName;

	@CaseSensitive(false)
	private String lastName;

	public String getFirstName() {
		return firstName;
	}

	@CaseSensitive(false)
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	// ...

}
net.comze

Versions

Version
3.3.2
3.3.1
3.3.0