DATASCOOTER
Support This Project
Custom Search

English Home
Russian Home
Quickstart
Performance
Guide
Download
Example
Contacts

Quickstart

Since 2.8.7 version start of datascooter become quite simple:
First - the simplest way - you may to start H2 database in memory mode - use 'org.datascooter.db.h2.MemoManagerBuilder':
	   IDataManager manager =	MemoManagerBuilder.build('dataManagerName','isDefault');
	    
Or later use
	   IDataManager manager =	Datascooter.getManager('dataManagerName');
	    
Or if 'isDefault' was set to true
	   IDataManager manager =	Datascooter.getDefault();
	    

And use the IDataManager for insert,select or delete data. It will work fast but only in memory - very useful for cashing or for testing purposes. Even without any mapping because datascooter will analyze structure of field of objects and save it in tables named according a class names. Datascooter may compose mapping use JPA annotations if they exists - it will be used for customization of mapping but it not required. In case of absence datascooter.properties will be used default properties. However would be better to create mapping - by eclipse extension point editor (my lovely) r just write XML by hand or programmatically:
	   	BundleFactory.create(Condition.class.getName(), null, "dsnip_condition", Condition.class.getName(), false, false);
		BundleFactory.setUseFieldAttributes(true);
		BundleFactory.createId("id", "ID", DBType.CHAR, C36, 0, true, true, false);
		BundleFactory.createReference("snipId", DataSnip.class.getName(), "snip_id", DBType.CHAR, C36, 0, true, true, false);
		BundleFactory.createPersist("isWhere", "is_where", DBType.BOOLEAN, 0, 0, true, true, true);
		BundleFactory.createPersist("operation", "operation_str", DBType.STRING, C36, 0, true, true, false);
		BundleFactory.createReference("parentId", Condition.class.getName(), "parent_id", DBType.CHAR, C36, 0, true, true, true);
		BundleFactory.createPersistChild("childList", Condition.class.getName(), null, PersistencePolicy.ALL, false, false, null, false);
		BundleFactory.createPersistChild("valueList", LogicValue.class.getName(), null, PersistencePolicy.ALL, false, false, null, false);
		BundleFactory.complete();
	    

After calling 'BundleFactory.complete();' creation of bundle will be complete with verifying table (checking or creation if not exists). 'BundleFactory.completeSilent();' - without verifying table.

Another way - use DataScooter.startZero(String propertiesPath, String url, String user, String password) - 'propertiesPath' may be null so will be used default properties, if 'url' do not start with 'jdbc:' but just simple directory path - so it will be used H2 data base. If 'url' starts with 'jdbc:' - will be loaded JDBC-driver for required database (be sure if required driver exists and in classpath) you may use drivers from datascooter.lib-2.9.zip

Another way - use 'org.datascooter.extension.DatascooterStarter' - it is utility class purposed for enable common start environments, just wrapper for Datascooter class starter methods :

DatascooterStarter.startZeroDefaultPath() - use start zero with default path - 'System.getProperty("user.dir")'

DatascooterStarter.startEclipseProduct() - use for start datascooter in eclipse application assume all required files (datascooter.properties, datasource.properties,plugin.xml) exists in the root of product plugin

DatascooterStarter.startEclipseDefaultPath() - use for start datascooter in eclipse application assume all required files (datascooter.properties, datasource.properties,plugin.xml) exists in the System.getProperty("user.dir")


If you develop an eclipse project - just include required plugins into project and make dependency where you use DataScooter from org.datascooter plugin. Required implementations and drivers will be loaded on demand by dependency injection depends on url of jdbs driver.

If you develop a java project - add datascooter-2.9.jar and jars of required drivers and libraries to class path.

Let's go ahead

So assume we work with Trades managed some Users who can cteates Trades, makes Offers and signing Contracts. If you are not sure about existence required tables in you database - lust call 'DataScooter.getDefault().verifyTables()' and all tables will be created or updated if they have not all fields.
So - just create users and save them to database:
	   public void createUsers() {
		user1 = new User("aa", "aaa");
		user2 = new User("aa", "sss");
		user3 = new User("aa", "aaa");
		user4 = new User("aa", "aaa");
		DataScooter.getDefault().save(user1);
		DataScooter.getDefault().save(user2);
		DataScooter.getDefault().save(user3);
		DataScooter.getDefault().save(user4);
	}
	   
	   public void createTrades() {
		trade1 = new Trade("trade1", "cart", 10L, new Date(), new Date(), user1.getId());
		trade2 = new Trade("trade2", "car", 10L, new Date(), new Date(), user4.getId());
		trade3 = new Trade("trade3", "track", 10L, new Date(), new Date(), user2.getId());
		trade4 = new Trade("trade4", "car", 10L, new Date(), new Date(), user3.getId());
		DataScooter.getDefault().save(trade1);
		DataScooter.getDefault().save(trade2);
		DataScooter.getDefault().save(trade3);
		DataScooter.getDefault().save(trade4);
		DataScooter.getDefault().save(new ChildTrade(trade1, "177"));
		DataScooter.getDefault().save(new ChildTrade(trade2, "2"));
		DataScooter.getDefault().save(new ChildTrade(trade2, "2"));
		DataScooter.getDefault().save(new ChildTrade(trade4, "0"));
		DataScooter.getDefault().save(new ChildTrade(trade4, "44"));
	}
	   
Create trades and save it again in the last strings creates special types of trades for illustration mapping if inheritance. Let's tald about it later.
	   	public void createOffers() {
		offer1 = new Offer("off1", trade1.getId(), 55L, new Date(), new Date(), user4.getId());
		offer2 = new Offer("off2", trade1.getId(), 55L, new Date(), new Date(), user2.getId());
		offer3 = new Offer("off3", trade2.getId(), 55L, new Date(), new Date(), user2.getId());
		offer4 = new Offer("off4", trade4.getId(), 55L, new Date(), new Date(), user2.getId());
		DataScooter.getDefault().save(offer1);
		DataScooter.getDefault().save(offer2);
		DataScooter.getDefault().save(offer3);
		DataScooter.getDefault().save(offer4);
	}
	   
Create and save offers for a trades a code of class 'Offer' looks like:
	  package org.datascooter.test.example;

import java.util.Date;

import org.datascooter.impl.Data;

public class Offer extends Data {

	private static final long serialVersionUID = -7688647132004333854L;
	public String name;
	public String tradeId;
	public Long price;
	public Date start;
	public Date stop;
	public String userId;

	public Offer() {
	}

	public Offer(String name, String tradeId, Long price, Date start, Date stop, String userId) {
		this.name = name;
		this.tradeId = tradeId;
		this.price = price;
		this.start = start;
		this.stop = stop;
		this.userId = userId;
	}

	@Override
	public String toString() {
		return name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTradeId() {
		return tradeId;
	}

	public void setTradeId(String tradeId) {
		this.tradeId = tradeId;
	}

	public Long getPrice() {
		return price;
	}

	public void setPrice(Long price) {
		this.price = price;
	}

	public Date getStart() {
		return start;
	}

	public void setStart(Date start) {
		this.start = start;
	}

	public Date getStop() {
		return stop;
	}

	public void setStop(Date stop) {
		this.stop = stop;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}
}
	   
	   
This is a mapping of it class: Captute You must not hard work with XML tags - just fill a form. Here you may to see how to map a simple attributes and a references to another classes
	   public void createContracts() {
		contract1 = new Contract("text1", trade1.getId(), offer1.getId());
		contract2 = new Contract("text2", trade3.getId(), offer2.getId());
		contract3 = new Contract("text3", trade2.getId(), offer3.getId());
		contract4 = new Contract("text4", trade4.getId(), offer4.getId());
		DataScooter.getDefault().save(contract1);
		DataScooter.getDefault().save(contract2);
		DataScooter.getDefault().save(contract3);
		DataScooter.getDefault().save(contract4);
	}
	   
Create and to save contracts between a owners of a trades and owners of a winned offer
	   public void testReferenceInvoke() {
		assertTrue(trade1.getUser().equals(user1));
		List list = trade1.getOfferList();
		List contractList = trade1.getContractList();
	}
	   
Here we check a ReferenceInvoker - standart method for invoking a referenced objects. It call may be take place inside method of object or in the aspect(AspectJ) intercepts this call. It let invoke referenced entities if it are mapped via 'ReferenceAttribute' or 'CrossReferenceAttribute'. By example method of the trade may raturn all offers received for a trade - this items are stored in the database, not in this trade.
	   public void testList() throws EntityNotMappedException, WrongMethodException,
	    SQLException, BuildClauseException, IOException {
		assertTrue("Count of trades:  " + DataScooter.getDefault().list
		(Trade.class.getName()).size(), (DataScooter.getDefault().list(
			Trade.class.getName()).size() == 4));
		assertTrue((DataScooter.getDefault().list(Offer.class.getName()).size() == 4));
		assertTrue((DataScooter.getDefault().list(Contract.class.getName()).size() == 4));
		assertTrue((DataScooter.getDefault().list(User.class.getName()).size() == 4));
	}
	   
Here we test invoking a list of objects
	    	public void testFirst() throws EntityNotMappedException, WrongMethodException,
	    	 SQLException, BuildClauseException, IOException {
		assertTrue(((Trade) DataScooter.getDefault().first(Trade.class.getName(),
		 "userId", user1.getId())).equals(trade1));
	}
	   
Now if you are not like DataSnip's you may use any complicated SQL queries -
Here we test a DQL - with smooth unintrusive syntax - just string without concatenation of class names or something else, even simpler than particular SQL queries - just use only aliases everywhere, a DOT notation is required everywhere, Spaces are required in queries whenever you want from datascooter to recognize and replace this part of string.
But DQL is database-specific - this example tested for MySQL 5.0 . A DataSnip is universal - it will be processed depends on selected type of data base.
	   	@Test
	public void testDQL() throws EntityNotMappedException, SecurityException, NoSuchMethodException {
		int count = DataScooter.getDefault().count(new DQuery(SnipType.FUNCTION, "select count(*) from t").
		addAlias("t", Offer.class).build());
		assertTrue("Offer count : " + count, count == 4);
		DataScooter.getDefault().showSQL(true);
		Offer offer = DataScooter.getDefault().first(new DQuery(Offer.class, "select t.* from t where t.userId = ?", "",
		 user4.getId()).addAlias("t", Offer.class).build());
		assertTrue("Offer: " + offer, offer.equals(offer1));
		offer = DataScooter.getDefault().first(new DQuery(Offer.class, "select * from t where t.userId = ?", "",
		user4.getId()).addAlias("t", Offer.class).build());
		assertTrue("Offer: " + offer, offer.equals(offer1));
		offer = DataScooter.getDefault().first(new DQuery(Offer.class, "from t where t.userId = ?", "",
		user4.getId()).addAlias("t", Offer.class).build());
		assertTrue("Offer: " + offer, offer.equals(offer1));
		List list = DataScooter.getDefault().list(new DQuery(Offer.class, "select * from t where t.userId = ?",
		 "", user4.getId()).addAlias("t", Offer.class).build());
		assertTrue("List: " + list, list.size() == 1);
		String query = "SELECT c.* FROM c WHERE c.offerId in (  SELECT o.id  FROM o  WHERE o.userId in
		(select u.id from u where u.firstName = ?))";
		List listContr = DataScooter.getDefault().list(
			new DQuery(Contract.class, query, "", "user4").addAlias("c", Contract.class).addAlias("o", Offer.class)
			.addAlias("u", NaturalUser.class).build());
		assertTrue("listContr: " + listContr, listContr.size() == 1);
		try {
			DataScooter.getDefault().list(new DQuery(Contract.class, query, "", "user4").addAlias("c", Contract.class)
			.addAlias("o", Offer.class).addAlias("u", User.class).build());
			assertTrue(false);
		} catch (DataScooterException e) {
		}
		DataScooter.getDefault().execute(
			new DQuery(SnipType.INSERT, "insert into  t ( t.id , t.name , t.tradeId , t.price , t.start , t.stop , t.userId )
			 values ( ? , ? , ? , ? , ? , ? , ? )", "", "dfgdsfetwetertwe", "off444",
				trade4.getId(), 55L, new Date(), new Date(), user2.getId()).addAlias("t", Offer.class).build());
		Offer offer444 = DataScooter.getDefault().first(new DQuery(Offer.class, "select t.* from t where t.name = ?", "", "off444")
		.addAlias("t", Offer.class).build());
		assertTrue(offer444 != null);
		DataScooter.getDefault().execute(new DQuery(SnipType.UPDATE, "update t set t.name = ? where t.name = ?",
		"", "off444xxx", "off444").addAlias("t", Offer.class).build());
		offer444 = DataScooter.getDefault().first(new DQuery(Offer.class, "select t.* from t where t.name = ?",
		"", "off444xxx").addAlias("t", Offer.class).build());
		assertTrue(offer444 != null);
		DataScooter.getDefault().execute(new DQuery(SnipType.DELETE, "delete from t where t.name = ?", "",
		"off444xxx").addAlias("t", Offer.class).build());
		offer444 = DataScooter.getDefault().first(new DQuery(Offer.class, "select t.* from t where t.name =
		 ?", "", "off444xxx").addAlias("t", Offer.class).build());
		assertTrue(offer444 == null);
	}
	   
	   
Here we test invoking the first object satisfying some conditions
	    public void testSelectCross() throws EntityNotMappedException, WrongMethodException,
	     SQLException, BuildClauseException, IOException {
		DataSnip dataSnip = DataSnip.select(Offer.class.getName());
		dataSnip.join(Contract.class.getName()).join(Trade.class.getName()).where("userId", user1.getId());
		assertTrue(((Offer) DataScooter.getDefault().first(dataSnip)).getId().equals(offer1.getId()));
		dataSnip = DataSnip.select(Trade.class.getName());
		dataSnip.join(Contract.class.getName()).join(Offer.class.getName()).where("userId", user2.getId());
		List dataList = DataScooter.getDefault().list(dataSnip);
		assertTrue(dataList.contains(trade2));
		assertTrue(dataList.contains(trade3));
		assertTrue(dataList.contains(trade4));
	}
	   
Here we test invoking offer on the trade with contract from trade owner 'user1'. Or trade for which yet signed a contract by offer from 'user2'.
	    public void testFetchByResult() throws EntityNotMappedException {
		DataSnip dataSnip = DataSnip.select(Trade.class.getName());
		dataSnip.whereId(trade1.getId());
		dataSnip.fetchByResult(Contract.class.getName()).fetchByResult(Offer.class.
		getName()).fetchByResult(User.class.getName());
		Snip snip = DataScooter.getDefault().retrieve(dataSnip);
		assertTrue("Wrong name: " + snip.getData()[0][1], snip.getData()[0][1].equals("trade1"));
		assertTrue(snip.getFetch()[0].getData()[0][1].equals("text1"));
		assertTrue(snip.getFetch()[0].getFetch()[0].getData()[0][1].equals("off1"));
		assertTrue(snip.getFetch()[0].getFetch()[0].getFetch()[0].getData()[0][1].equals("aa"));
		DataScooter.getDefault().deleteSnip(snip);
		Snip snipDeleted = DataScooter.getDefault().retrieve(dataSnip);
		assertTrue(snipDeleted.getData().length == 0);
		DataScooter.getDefault().saveSnip(snip);
		snip = DataScooter.getDefault().retrieve(dataSnip);
		assertTrue(snip.getData()[0][1].equals("trade1"));
		assertTrue(snip.getFetch()[0].getData()[0][1].equals("text1"));
		assertTrue(snip.getFetch()[0].getFetch()[0].getData()[0][1].equals("off1"));
		assertTrue(snip.getFetch()[0].getFetch()[0].getFetch()[0].getData()[0][1].equals("aa"));
	}
	   
And here we want invoke a trade with id 'trade1.getId()' and invoke all the contracts for this trade, all offers with contracts to this trade and all users who made this offers-
	    Snip snip = DataScooter.getDefault().retrieve(dataSnip);
	   
And we receive all it hierarchy of objects inside of object 'Snip' - only one request to datascooter!
	    DataScooter.getDefault().deleteSnip(snip);
	   
Now let's delete this hierarchy whole from a database by one click...
	    DataScooter.getDefault().saveSnip(snip);
	   
Here let's again to save this hierarchy into database by one click and check all this objects - it are again on-site! It is unique possibility only from datascooter!
	    public void testFetch() throws EntityNotMappedException {
		DataSnip dataSnip = DataSnip.select(Trade.class.getName());
		dataSnip.whereId(trade1.getId());
		dataSnip.fetch(Contract.class.getName());
		dataSnip.fetch(Offer.class.getName());
		dataSnip.fetch(User.class.getName());
		Snip snip = DataScooter.getDefault().retrieve(dataSnip);
		assertTrue(snip.getData()[0][1].equals("trade1"));
		assertTrue(snip.getFetch()[0].getData()[0].length == 4);
		assertTrue(snip.getFetch()[0].getData()[1].length == 4);
		assertTrue(snip.getFetch()[0].getData()[2].length == 4);
	}
	   
Here we just to select from databse specified trade and all required for a remote working - a list of contracts, list of offers and list of users - binded or not with this trade
	    public void testUpdate() throws EntityNotMappedException, WrongMethodException,
	    SQLException, BuildClauseException, IOException {
		DataScooter.getDefault().update(trade1, "goods", "Toyota");
		DataScooter.getDefault().update(trade2, "goods", "BMW");
		assertTrue(((Trade) DataScooter.getDefault().firstById(Trade.class.getName(),
		 trade1.getId())).getGoods().equals("Toyota"));
		assertTrue(((Trade) DataScooter.getDefault().firstById(Trade.class.getName(),
		 trade2.getId())).getGoods().equals("BMW"));
	}
	   
Here we test update of trades
	    public void testDelete() throws EntityNotMappedException, WrongMethodException,
	     SQLException, BuildClauseException, IOException {
		DataScooter.getDefault().delete(trade1);
		DataScooter.getDefault().delete(Trade.class.getName(), "goods", "BMW");
		assertTrue(DataScooter.getDefault().firstById(Trade.class.getName(),
		 trade1.getId()) == null);
		assertTrue(DataScooter.getDefault().first(Trade.class.getName(), "goods", "BMW") == null);
	}
	   
Here we test a deletion objects from database Тестируем удаление объектов из базы
	    	public void testECount() {
		assertTrue(DataScooter.getDefault().count(Trade.class.getName()) == 2);
		assertTrue(DataScooter.getDefault().count(Offer.class.getName()) == 4);
	}
	   
Let's count items in database Подсчитываем количество объектов в базе
	    public void testSaveOrUpdate() throws EntityNotMappedException,
	    WrongMethodException, SQLException, BuildClauseException, IOException {
		DataScooter.getDefault().saveOrUpdate(trade1);
		trade1.setGoods("Subaru");
		DataScooter.getDefault().saveOrUpdate(trade1);
		assertTrue(DataScooter.getDefault().first(Trade.class.getName(),
		 "goods", "Subaru") != null);
	}
	   
Here we make save or update - for cases when we do not know about existence object in the databse
	    	public void testSaveAll() throws EntityNotMappedException,
	    	WrongMethodException, SQLException, BuildClauseException, IOException {
		list.add(new Offer("List", trade1.getId(), 55L, new Date(), new Date(), user4.getId()));
		list.add(new Offer("List", trade1.getId(), 55L, new Date(), new Date(), user2.getId()));
		list.add(new Offer("List", trade2.getId(), 55L, new Date(), new Date(), user2.getId()));
		list.add(new Offer("List", trade4.getId(), 55L, new Date(), new Date(), user2.getId()));
		DataScooter.getDefault().saveAll(list);
		assertTrue("Offers in the db: " + DataScooter.getDefault().list
		(Offer.class.getName(), "name", "List").size(), DataScooter.getDefault().list(
			Offer.class.getName(),
			"name",
			"List").size() == 4);
	}
	   
Test saving a list of objects
	    public void testDeleteAll() throws EntityNotMappedException, WrongMethodException,
	    BuildClauseException, SQLException, IOException {
		DataScooter.getDefault().deleteAll(list);
		assertTrue(DataScooter.getDefault().list(Offer.class.getName(), "name", "List").size() == 0);
	}
	   
Test deleting a list of objects
	    public void testPagination() throws EntityNotMappedException, WrongMethodException,
	    SQLException, BuildClauseException, IOException {
		Date start = new Date();
		list1.add(new Offer("List2", trade1.getId(), 55L, start, start, user4.getId()));
		list1.add(new Offer("List2", trade1.getId(), 55L, start, start, user2.getId()));
		list1.add(new Offer("List2", trade2.getId(), 55L, start, start, user2.getId()));
		list1.add(new Offer("List2", trade4.getId(), 55L, start, start, user2.getId()));
		list1.add(new Offer("List2", trade1.getId(), 55L, start, start, user4.getId()));
		list1.add(new Offer("List2", trade1.getId(), 55L, start, start, user2.getId()));
		list1.add(new Offer("List2", trade2.getId(), 55L, start, start, user2.getId()));
		list1.add(new Offer("List2", trade4.getId(), 55L, start, start, user2.getId()));
		DataScooter.getDefault().saveAll(list1);
		assertTrue("Pagination error " + DataScooter.getDefault().list(Offer.class.getName(),
		 1, 2).size(), DataScooter.getDefault().list(
			Offer.class.getName(),
			1,
			2).size() == 2);
		assertTrue("Pagination error " + DataScooter.getDefault().list(Offer.class.getName(),
		 "name", "List2", 2, 18).size(), DataScooter
			.getDefault().list(Offer.class.getName(), "name", "List2", 2, 18).size() == 6);
	}
	   
Here we test pagination - invoking a big count of objects by part
	    	public void testGroupFetch() throws EntityNotMappedException {
		DataSnip dataSnip = DataSnip.group();
		dataSnip.fetch(Contract.class.getName());
		dataSnip.fetch(Offer.class.getName());
		dataSnip.fetch(User.class.getName());
		Snip snip = DataScooter.getDefault().retrieve(dataSnip);
		assertTrue(snip.getData() == null);
		assertTrue(snip.getFetch()[0].getData()[0].length == 4);
		assertTrue(snip.getFetch()[0].getData()[1].length == 4);
		assertTrue(snip.getFetch()[0].getData()[2].length == 4);
	}
	   
Here we test invoking a arbitary set of objects
	    	public void testPipe() throws SnipManagerException, EntityNotMappedException,
	    	 SQLException, BuildClauseException, IOException {
		DataScooter.getInstance().putSource(new DataSource("mysql-1",
		 "jdbc:mysql://localhost/testtest", "root", "root", "mysql", false));
		IDataManager manager = DataScooter.getInstance().getManager("mysql-1");
		manager.verifyTables(true);
		TestUtils.clearAll(manager);
		int count1 = DataScooter.getDefault().count(Trade.class.getName());
		manager.saveSnip(DataScooter.getDefault().retrieve(DataSnip.select(Trade.class.getName())));
		int count = manager.count(Trade.class.getName());
		assertTrue("Size: " + count + "---" + count1, count == count1);
	}
	   
And here we test pumping a list of objects from one database from other
	    manager.saveSnip(DataScooter.getDefault().retrieve(DataSnip.select(Trade.class.getName())));
	   
Only one string makes saving and invoking
	    	public void testDataSet() throws SnipManagerException, EntityNotMappedException,
	    	 SQLException, BuildClauseException, IOException {
		String entity = "someObject";
		EntityBundle bundle = new EntityBundle(entity, null, "SomeTable", null, null);
		bundle.setId(new SimpleAttribute("id", "id", DBType.CHAR, new Integer(36), null, Boolean.TRUE));
		bundle.addSimpleAttribute(new SimpleAttribute("first", "first", DBType.STRING, new Integer(55), null, null));
		bundle.addSimpleAttribute(new SimpleAttribute("second", "second", DBType.INT, null, null, null));
		DataScooter.getInstance().addBundle(bundle, true);
		DataScooter.getDefault().clear(entity);
		int i = 5555;
		String string = "atom";
		DataScooter.getDefault().saveSet(entity, UUID.randomUUID().toString(), string, i);
		Snip snip = DataScooter.getDefault().retrieve(DataSnip.select(entity));
		assertTrue("Size: " + snip.getData().length, snip.getData().length == 1);
		assertTrue("Attribute: " + snip.getData()[0][1], snip.getData()[0][1].equals(string));
		BigDecimal bb = new BigDecimal(snip.getData()[0][2] + "");
		assertTrue("Attribute: " + snip.getData()[0][2], bb.intValue() == i);
		snip.getData()[0][1] = string + "bbb";
		snip.getData()[0][2] = i + 1;
		DataScooter.getDefault().updateSnip(snip);
		snip = DataScooter.getDefault().retrieve(DataSnip.select(entity));
		assertTrue("Size: " + snip.getData().length, snip.getData().length == 1);
		assertTrue("Attribute: " + snip.getData()[0][1], snip.getData()[0][1].equals(string + "bbb"));
		bb = new BigDecimal(snip.getData()[0][2] + "");
		assertTrue("Attribute: " + snip.getData()[0][2], bb.intValue() == i + 1);
		DataScooter.getDefault().deleteSnip(snip);
		snip = DataScooter.getDefault().retrieve(DataSnip.select(entity));
		assertTrue("Size not empty : " + snip.getData().length, snip.getData().length == 0);
		String entity1 = "someObject1";
		EntityBundle bundle1 = new EntityBundle(entity1, null, "d_trade", null, null);
		bundle1.setId(new SimpleAttribute("id", "s_id", DBType.CHAR, new Integer(36), null, Boolean.TRUE));
		bundle1.addSimpleAttribute(new SimpleAttribute("name", "s_name",
		 DBType.STRING, new Integer(36), null, null));
		bundle1.addSimpleAttribute(new SimpleAttribute("goods", "s_goods", DBType.STRING, null, null, null));
		bundle1.addSimpleAttribute(new SimpleAttribute("type", "s_type", DBType.INT, null, null, null));
		bundle1.setDiscriminator(new Condition(new LogicValue("type", Constraint.EQUAL.name(), 0)));
		DataScooter.getInstance().addBundle(bundle1, false);
		Snip snip1 = DataScooter.getDefault().retrieve(DataSnip.select(entity1));
		assertTrue("Size of trades substitutor: " + snip1.getData().length, snip1.getData().length == 3);
	}
	   
This a long example shows use a sets of data - i.e. mappings without objects(classes). The mapping without class - it is just a named set of data from one table and you may to make with it all datascooter operations - save,update,invoke, delete.
	    String entity = "someObject";
	    EntityBundle bundle = new EntityBundle(entity, null, "SomeTable", null, null);
		bundle.setId(new SimpleAttribute("id", "id", DBType.CHAR, new Integer(36), null, Boolean.TRUE));
		bundle.addSimpleAttribute(new SimpleAttribute("first", "first",
		 DBType.STRING, new Integer(55), null, null));
		bundle.addSimpleAttribute(new SimpleAttribute("second", "second", DBType.INT, null, null, null));
		DataScooter.getInstance().addBundle(bundle, true);
	   
EntityBundle - this is a mapping holder - here we create it and in the last string insert in to datascooter. Now we can to manipulate it object.
	    DataScooter.getDefault().saveSet(entity, UUID.randomUUID().toString(), string, i);
	   
Here we create a set of data - just a sequence of fields
	    snip = DataScooter.getDefault().retrieve(DataSnip.select(entity));
	   
И извлекаем его же.
	 public void testLogicAttributes() throws SnipManagerException,
	    EntityNotMappedException, SQLException, BuildClauseException, IOException {
		List list2 = DataScooter.getDefault().list(ChildTrade.class.getName());
		assertTrue("Subset count wrong: " + list2.size(), (list2.size() == 1));
	}
	   
And here we test invoking a list of descendants of trade stored in the same table - datascooter will newer mix it - it may invoke it by logic clause('logic_condition') of any complexity. It is a complex discriminator - i've never seen similar. Here may be it looks not clear but it is not a problem - in the standart editor of a extension points you will just fillup forms.
So it looks in the extension points editor:

CaptuteLogic
	 public void testSnipQuery() throws SnipManagerException, EntityNotMappedException,
	     SQLException, BuildClauseException, IOException {
		EclipseQueryProvider provider = new EclipseQueryProvider();
		provider.explore();
		DataSnip query = provider.getItem("selectOffer");
		assertTrue(query != null);
		Snip snip = DataScooter.getDefault().retrieve(query);
		assertTrue("First offer " + snip.getData()[0][1], snip.getData()[0][1].equals("off4"));
		assertTrue("First contract " + snip.getFetch()[0].getData()[0][1],
		snip.getFetch()[0].getData()[0][1].equals("text1")
			|| snip.getFetch()[0].getData()[0][1].equals("text2")
			|| snip.getFetch()[0].getData()[0][1].equals("text3")
			|| snip.getFetch()[0].getData()[0][1].equals("text4"));
		assertTrue("Second contract " + snip.getFetch()[0].getData()[1][1],
		snip.getFetch()[0].getData()[1][1].equals("text1")
			|| snip.getFetch()[0].getData()[1][1].equals("text2")
			|| snip.getFetch()[0].getData()[1][1].equals("text3")
			|| snip.getFetch()[0].getData()[1][1].equals("text4"));
		assertTrue("First trade " + snip.getFetch()[0].getFetch()[0].getData()[0][1],
		snip.getFetch()[0].getFetch()[0].getData()[0][1]
			.equals("trade1")
			|| snip.getFetch()[0].getFetch()[0].getData()[0][1].equals("trade3")
			|| snip.getFetch()[0].getFetch()[0].getData()[0][1].equals("trade4"));
		assertTrue("s" + snip.getFetch()[0].getFetch()[0].getData()[1][1],
		snip.getFetch()[0].getFetch()[0].getData()[1][1].equals("trade4")
			|| snip.getFetch()[0].getFetch()[0].getData()[1][1].equals("trade3")
			|| snip.getFetch()[0].getFetch()[0].getData()[1][1].equals("trade1"));
	}
	   
It is too very interesting thing - SnipQuery - it is made with extension points tool for a writing predefined hierarchical queries holds all the possibilities of datascooter.
So it looks in the extension points editor:

Capture
Here we try to save snips with different SnipPolicy - EXECUTE, EXECUTE_AND_LOG - so you may only execute or and log executed objects and execute them later many ttimes
		@Test
	public void testSnipSave() throws EntityNotMappedException, SecurityException, NoSuchMethodException {
		SnipPolicy policy = DataScooter.getDefault().getSnipPolicy();
		assertTrue("SnipPolicy:  " + policy, policy.equals(SnipPolicy.EXECUTE));
		DataScooter.getDefault().setSnipPolicy(SnipPolicy.EXECUTE_AND_LOG);
		policy = DataScooter.getDefault().getSnipPolicy();
		assertTrue("SnipPolicy:  " + policy, policy.equals(SnipPolicy.EXECUTE_AND_LOG));
		DataSnip update = DataSnipFactory.update(Trade.class.getName()).whereId(trade3.getId()).what("goods", "Mersedes");
		DataScooter.getDefault().update(update);
		DataScooter.getDefault().update(trade4, "goods", "Volvo");
		int count = DataScooter.getDefault().count(DataSnip.class.getName());
		DataScooter.getDefault().setSnipPolicy(SnipPolicy.EXECUTE);
		assertTrue("DataSnip count : " + count, count == 2);
		int count1 = DataScooter.getDefault().count(Condition.class.getName());
		assertTrue("Condition count : " + count1, count1 == 6);
		int count2 = DataScooter.getDefault().count(LogicValue.class.getName());
		assertTrue("LogicValue count : " + count2, count2 == 6);
		String id = update.getId();
		try {
			DataSnip first = DataScooter.getDefault().firstById(DataSnip.class, id);
			assertTrue("Id :  " + first.where.valueList.get(0).attribute, first.where.valueList.get(0).attribute.equals("id"));
			assertTrue(first.where.valueList.get(0).getValue().equals(trade3.getId()));
			assertTrue("Attribute :  " + first.what.valueList.get(0).attribute, first.what.valueList.get(0).
			attribute.equals("goods"));
			assertTrue(first.what.valueList.get(0).getValue().equals("Mersedes"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		DataScooter.getDefault().update(trade3, "goods", "Volvo");
		trade3 = DataScooter.getDefault().firstById(Trade.class, trade3.getId());
		assertTrue("trade3.getGoods = " + trade3.getGoods(), trade3.getGoods().equals("Volvo"));
		update = DataScooter.getDefault().firstById(DataSnip.class, update.getId());
		DataScooter.getDefault().execute(update);
		trade3 = DataScooter.getDefault().firstById(Trade.class, trade3.getId());
		assertTrue(trade3.getGoods().equals("Mersedes"));
	}
	   

Here we test a pertial select - when you do not want to select some parts of object - just exclude it
		@Test
	public void testPartialSelect() throws SecurityException, NoSuchMethodException, EntityNotMappedException {
		DataSnip select = null;
		DataSnip select1 = null;
		select = DataSnipFactory.select(NaturalUser.class.getName()).whereId(user2.getId()).exclude("lastName");
		select1 = DataSnipFactory.select(NaturalUser.class.getName()).whereId(user2.getId()).include("lastName");
		user2 = DataScooter.getDefault().first(select);
		assertTrue(user2.getLastName() == null);
		user2 = DataScooter.getDefault().first(select1);
		assertTrue(" FirstName = " + user2.getFirstName(), user2.getFirstName() == null);
	}
	   

Test references - it is illustartion of mapping and invocking a referenced objects - so you may to invoke all contracts where user was as winner:
		@Test
	public void testReferences() {
		Map winContractsMap = user1.getWinContractsMap();
		List winContractsList = user1.getWinContractsList();
		Set winContractsSet = user1.getWinContractsSet();
		assertTrue(winContractsList.size() == 3);
		assertTrue(winContractsMap.size() == 3);
		assertTrue(winContractsSet.size() == 3);
	}
	   

Here we demonstrate interesting option - you may to fetch a composite of linked objects and save or update it many times later as one query.
		@Test
	public void testSaveOrUpdateSnip() throws EntityNotMappedException, SecurityException, NoSuchMethodException {
		DataSnip dataSnip = DataSnipFactory.select(Trade.class.getName());
		dataSnip.whereId(trade1.getId());
		dataSnip.fetch(Contract.class.getName());
		dataSnip.fetch(Offer.class.getName());
		dataSnip.fetch(NaturalUser.class.getName());
		Snip snip = DataScooter.getDefault().retrieve(dataSnip);
		DataScooter.getDefault().delete(Trade.class);
		DataScooter.getDefault().delete(NaturalUser.class);
		assertTrue(DataScooter.getDefault().list(NaturalUser.class).size() == 0);
		assertTrue(DataScooter.getDefault().list(Trade.class).size() == 0);
		DataScooter.getDefault().saveOrUpdate(snip);
		Object firstById = DataScooter.getDefault().first(Trade.class);
		assertTrue(firstById.equals(trade1));
		List list2 = DataScooter.getDefault().list(NaturalUser.class);
		assertTrue("User count = " + list2.size(), list2.size() == 4);
	}
	   
	
Here we test useful option - 'container attributes' - it late us to save and select a included into targer object composite objects:
		@Test
	public void testContainerAttribute() throws EntityNotMappedException, IllegalArgumentException, IllegalAccessException,
	 InvocationTargetException, SecurityException, NoSuchMethodException {
		Location location = new Location();
		location.addPhone(new Phone("222222", 777, PhoneType.HOME));
		location.addPhone(new Phone("333333", 777, PhoneType.MOBILE));
		location.addOwner(new Owner("0dd3", "Bob", "Smith"));
		location.addOwner(new Owner("xf4", "Ann", "Cox"));
		Address address = new Address("221b Baker st.", "London", "England");
		address.setBox(new PostBox("000023", "Liverpool", true));
		location.setAddress(address);
		user5 = new NaturalUser("simple", "srtfhrty", "Holmes", "Sherlock");
		user5.setLocation(location);
		DataScooter.getDefault().save(user5);
		String id = user5.getId();
		user5 = null;
		user5 = DataScooter.getDefault().firstById(NaturalUser.class, id);
		assertTrue("Location = " + user5.getLocation(), user5.getLocation() != null);
		assertTrue("Phone List = " + user5.getLocation().getPhoneList().size(), user5.getLocation().getPhoneList().size() == 2);
		assertTrue("Phone Types = " + user5.getLocation().getPhoneList().get(0).getType(), user5.getLocation().getPhoneList().
		get(0).getType() != null);
		assertTrue("Owner Map = " + user5.getLocation().getOwnerMap().size(), user5.getLocation().getOwnerMap().size() == 2);
		assertTrue("Address = " + user5.getLocation().getAddress(), user5.getLocation().getAddress() != null);
		assertTrue("Address: City: = " + user5.getLocation().getAddress().getCity(), user5.getLocation().getAddress().
		getCity() != null && user5.getLocation().getAddress().getCity().equals("London"));
		assertTrue("Login = " + user5.getLogin(), user5.getLogin().equals("simple"));
		assertTrue("Password = " + user5.getPassword(), user5.getPassword().equals("srtfhrty"));
		user5.getLocation().setRemark("Changed");
		DataScooter.getDefault().saveOrUpdate(user5);
		int count = DataScooter.getDefault().count(Location.class);
		assertTrue("Location count = " + count, count == 1);
		count = DataScooter.getDefault().count(Phone.class);
		assertTrue("Phone count = " + count, count == 2);
		count = DataScooter.getDefault().count(Owner.class);
		assertTrue("Owner count = " + count, count == 2);
		Map ownerMapLazy = user5.getLocation().getOwnerMapLazy();
		assertTrue("Owner Map Lazy = " + ownerMapLazy.size(), ownerMapLazy.size() == 2);
		assertTrue("Owner Map not contains Ann", ownerMapLazy.get("xf4").getFirstName().equals("Ann"));
		assertTrue("Owner Map not contains Bob", ownerMapLazy.get("0dd3").getFirstName().equals("Bob"));
		//
		Owner owner = new Owner("wwww", "Awwwnn", "Ceeeox");
		DataScooter.getDefault().getInstanceManager().saveContent(location, "ownerMap", owner);
		// user5 = DataScooter.getDefault().firstById(NaturalUser.class, id);
		// location = user5.getLocation();
		location = DataScooter.getDefault().firstById(Location.class, location.getId());
		assertTrue("Owner Map = " + location.getOwnerMap().size(), location.getOwnerMap().size() == 3);
		DataScooter.getDefault().getInstanceManager().removeContent(location, "ownerMap", owner);
		location = DataScooter.getDefault().first(location);
		assertTrue("Owner Map = " + location.getOwnerMap().size(), location.getOwnerMap().size() == 2);
		//
		DataScooter.getDefault().delete(user5);
		count = DataScooter.getDefault().count(Location.class);
		assertTrue("Location count = " + count, count == 0);
		count = DataScooter.getDefault().count(Phone.class);
		assertTrue("Phone count = " + count, count == 0);
		count = DataScooter.getDefault().count(Owner.class);
		assertTrue("Owner count = " + count, count == 0);
	}
	   

Here we test an embedded storage - when objects has one to one relations - it may be stored in one table, but by selection it will be instatntiated as different objects
		@Test
	public void testEmbedded() {
		PostBox box = user5.getLocation().getAddress().getBox();
		assertTrue("Address Post Box Not found", box != null && box.getBoxIndex().equals("000023"));
	}
	   

Here we test transactions
	@Test
	public void testTransaction3() {
		DataScooter.getDefault().saveOrUpdate(trade3);
		DataScooter.getDefault().beginTransaction("first");
		DataScooter.getDefault().update(contract1, "texts", "xxxxxxxxxxxx");
		DataScooter.getDefault().rollback();
		contract1 = DataScooter.getDefault().firstById(Contract.class, contract1.getId());
		assertTrue("contract1.getTexts() = " + contract1.getTexts(), !contract1.getTexts().equals("xxxxxxxxxxxx"));
		DataScooter.getDefault().beginTransaction("second");
		DataScooter.getDefault().update(contract1, "texts", "yyyyyyyy");
		DataScooter.getDefault().update(trade3, "goods", "Honda");
		DataScooter.getDefault().commit();
		contract1 = DataScooter.getDefault().firstById(Contract.class, contract1.getId());
		trade2 = DataScooter.getDefault().firstById(Trade.class, trade2.getId());
		trade3 = DataScooter.getDefault().firstById(Trade.class, trade3.getId());
		assertTrue("trade3.getGoods = " + trade3.getGoods(), trade3.getGoods().equals("Honda"));
		assertTrue("contract1.getTexts() = " + contract1.getTexts(), contract1.getTexts().equals("yyyyyyyy"));
		
	}
	
	
	@Test
	public void testTransaction() {
		DataScooter.getDefault().saveOrUpdate(trade3);
		DataSnip group = DataSnipFactory.group();
		group.fetch(DataSnipFactory.update(trade1).what("goods", "Volvo12"));
		group.fetch(DataSnipFactory.update(trade3).what("goods", "Honda"));
		group.fetch(DataSnipFactory.update(offer1).what("name", "Honda"));
		DataScooter.getDefault().beginTransaction("first");
		DataScooter.getDefault().execute(group);
		DataScooter.getDefault().commit();
		trade1 = DataScooter.getDefault().firstById(Trade.class, trade1.getId());
		offer1 = DataScooter.getDefault().firstById(Offer.class, offer1.getId());
		trade3 = DataScooter.getDefault().firstById(Trade.class, trade3.getId());
		assertTrue("trade1.getGoods = " + trade1.getGoods(), trade1.getGoods().equals("Volvo12"));
		assertTrue("offer1.getGoods = " + offer1.getName(), offer1.getName().equals("Honda"));
		assertTrue("trade3.getGoods = " + trade3.getGoods(), trade3.getGoods().equals("Honda"));
	}
	   
Another cool feature - distributed transactions even with different databases
		@Test
	public void testDistributedTransaction() throws EntityNotMappedException, SnipManagerException, SQLException {
		IDataManager manager = DataScooter.getManager(H2PIPE);
		manager.dropAll("", true);
		manager.verifyTables();
		DataSnip dataSnip = DataScooter.getDefault().getInstanceManager().flush(trade44);
		Transaction transaction = new Transaction("test");
		transaction.addTask(new Task(manager, dataSnip));
		transaction.addTask(new Task(DataScooter.getDefault(), dataSnip));
		transaction.runSync();
		trade44 = DataScooter.getDefault().firstById(Trade.class, trade44.getId());
		assertTrue(trade44 != null);
		trade44 = manager.firstById(Trade.class, trade44.getId());
		assertTrue(trade44 != null);
	}
	   

Here we test a bundle validation policy - the tables may be validated if bundle changes
		@Test
	public void validationPolicy() {
		TableValidationPolicy policy = DataScooter.getDefault().getValidationPolicy();
		assertTrue("TableValidationPolicy:  " + policy, policy.equals(TableValidationPolicy.BY_BUNDLE_CHANGE));
		DataScooter.getDefault().setValidationPolicy(TableValidationPolicy.NEVER);
		policy = DataScooter.getDefault().getValidationPolicy();
		assertTrue("TableValidationPolicy:  " + policy, policy.equals(TableValidationPolicy.NEVER));
	}
	   

For debugging purposes very useful to see executed sql even with returned values - so - this is it
		@Test
	public void showSQL() {
		DataScooter.getDefault().showSQL(true);
		DataScooter.getDefault().count(Trade.class, "goods", "car");
		DataScooter.getDefault().showSQL(false);
		DataScooter.getDefault().showRetrieveSQL(true);
		assertTrue(((Trade) DataScooter.getDefault().first(Trade.class.getName(), "userId", user1.getId())).equals(trade1));
		DataScooter.getDefault().showRetrieveSQL(false);
	}
	   

Here we test drop and create of tables
		@Test
	public void testCreateDrop() {
		boolean tableExists = DataScooter.getDefault().tableExists(Trade.class);
		assertTrue("Table for trade not  exists:  " + tableExists, tableExists);
		DataScooter.getDefault().drop(Trade.class);
		tableExists = DataScooter.getDefault().tableExists(Trade.class);
		assertTrue("Table for trade exists:  " + tableExists, !tableExists);
		DataScooter.getDefault().create(Trade.class);
		tableExists = DataScooter.getDefault().tableExists(Trade.class);
		assertTrue("Table for trade not  exists:  " + tableExists, tableExists);
	}
	   

Here we test drop and create of many tables in group, with include/exclude some of it
		@Test
	public void testClearAll() throws EntityNotMappedException, SecurityException, NoSuchMethodException {
		EntityBundle bundle = DSMapper.getBundle(Trade.class);
		DataScooter.getDefault().clearAll(null, true, bundle.table);
		int count = DataScooter.getDefault().count(Trade.class);
		assertTrue(count == 0);
	}
	   

Here we test a default implementation of cashe
		@Test
	public void testCashe() throws EntityNotMappedException, SecurityException, NoSuchMethodException, InterruptedException {
		DataScooter.getDefault().verifyTable(DSMapper.getBundle(IntCountry.class));
		TestUtils.prepareCountry();
		long nanoTime = System.nanoTime();
		int size = DataScooter.getDefault().list(IntCountry.class).size();
		DataScooter.getDefault().list(IntCountry.class);
		DataScooter.getDefault().list(IntCountry.class);
		long withoutCache = System.nanoTime() - nanoTime;
		DSSettings.setDefaultDataCacheSize(1000);
		DSSettings.setUseDataCache(true);
		DSCacheLoader.addRegion(new CacheRegion(IntCountry.class.getName(), 1000, true, -1, -1, false, false, null,
		DataSnipFactory.select(IntCountry.class)));
		DataScooter.getDefault().reloadCache();
		nanoTime = System.nanoTime();
		int size2 = DataScooter.getDefault().list(IntCountry.class).size();
		assertTrue(size2 == size);
		DataScooter.getDefault().list(IntCountry.class);
		DataScooter.getDefault().list(IntCountry.class);
		long withCache = System.nanoTime() - nanoTime;
		assertTrue("Duration: withCache: " + withCache + " - " + withoutCache + " : withoutCache ", withCache < withoutCache);
		System.out
			.println(DataScooter.getDefault().getCasheManager().getDataCache().getClass().getName() +
			"---withCache--" + withCache + "----------withoutCache---" + withoutCache + "  nanoseconds");
		IntCountry country = DataScooter.getDefault().first(IntCountry.class, "shortName", "JP");
		assertTrue(country != null);
		Thread.sleep(2000);
		int size3 = DataScooter.getDefault().list(IntCountry.class).size();
		assertTrue(size3 == size);
	}
	   

Here we test verification of tables - creation if not exists, checking of consistency of all columns
	@Test
	public void testVerify() throws EntityNotMappedException, SecurityException, NoSuchMethodException {
		EntityBundle bundle = DSMapper.getBundle(Trade.class);
		bundle.getAttribute("goods").setScale(3333);
		DataScooter.getDefault().verifyTable(bundle);
		bundle.id.setType(DBType.INT);
		try {
			DataScooter.getDefault().verifyTable(bundle);
			assertTrue(false);
		} catch (Exception e) {
		}
		try {
			DataScooter.getDefault().verifyTables();
			// assertTrue(false);
		} catch (Exception e) {
		}
		bundle.id.setType(DBType.CHAR);
	}
	   

Here we test backup of tables of any databases with many additional features as replace some values and so on
		@Test
	public void testBackup() throws EntityNotMappedException, SQLException, IOException, SnipManagerException,
	SecurityException, NoSuchMethodException {
		try {
			int TESTCOUNT = 99;
			String TEST_BACK_SQL = "test_back.sql";
			String TEST_BACK_BACK = "test_back.back";
			String userDir = System.getProperty("user.dir");
			File file = new File(userDir, "backuptest");
			if (!file.exists()) {
				file.mkdirs();
			} else {
				LangUtils.clearDir(file);
			}
			List list = new ArrayList();
			for (int a = 0; a < TESTCOUNT; a++) {
				list.add(new ContextTestClassInt(a + 10, null));
			}
			DataScooter.getDefault().dropAll("", true);
			DSMapper.clear();
			DSSettings.setBuildForeignKeys(true);
			DSMapper.getBundle(ContextTestClassInt.class);
			DataScooter.getDefault().verifyTables();
			DataScooter.getDefault().batchSave(list);
			int count = DataScooter.getDefault().count(ContextTestClassInt.class);
			assertTrue("***ContextTestClassInt count :  " + count, count == TESTCOUNT);
			IBackupManager backup = DataScooter.getDefault().getBackup();
			backup.backup("", file.getPath(), TEST_BACK_BACK, BackupPolicy.ALL_TABLES, true);
			backup.backupToSql("", file.getPath(), TEST_BACK_SQL, BackupPolicy.NOT_EMPTY_TABLES, true);
			DataScooter.getDefault().dropAll(null, true);
			assertTrue(!DataScooter.getDefault().tableExists(ContextTestClassInt.class));
			backup.restore("", file.getPath(), TEST_BACK_BACK, RestorePolicy.TRY_TO_CREATE, true);
			assertTrue(DataScooter.getDefault().tableExists(ContextTestClassInt.class));
			assertTrue(DataScooter.getDefault().count(ContextTestClassInt.class) == TESTCOUNT);
			assertTrue(DataScooter.getDefault().count(ContextTestClassInt.class) == TESTCOUNT);
			LangUtils.clearDir(file);
			backup = DataScooter.getDefault().getBackup();
			backup.setExecuteBefore(new File(userDir, "before.sql"));
			String tableName = "t_context_test_class_int";
			String shtableName = "testtest.t_context_test_class_int";
			backup.setExecuteBefore("update " + shtableName + " set F_STRING_VALUE='ddddd';");
			backup.setExecuteAfter(new File(userDir, "after.sql"));
			backup.setExecuteAfter("update " + shtableName + " set F_STRING_VALUE='000';");
			backup.setDataReplace(
				new TableReplace(tableName, new ColumnReplace("F_STRING_VALUE", "00")),
				new TableReplace(tableName, new ColumnReplace("F_LONG_VALUE", 100L, 9L, Constraint.EQUAL)),
				new TableReplace(tableName, new ColumnReplace("F_LONG_VALUE", 100L, 1L, Constraint.LESS_THAN)));
			backup.backup("", file.getPath(), TEST_BACK_BACK, BackupPolicy.ALL_TABLES, true, tableName);
			backup = DataScooter.getDefault().getBackup();
			backup.backupToSql("", file.getPath(), TEST_BACK_SQL, BackupPolicy.ALL_TABLES, true, tableName);
			DataScooter.getDefault().dropAll(null, true, tableName);
			backup = DataScooter.getDefault().getBackup();
			backup.restore("", file.getPath(), TEST_BACK_BACK, RestorePolicy.TRY_TO_CREATE_SILENT, true);
			ContextTestClassInt first = DataScooter.getDefault().first(ContextTestClassInt.class, "longValue", 100L);
			assertTrue("String value = " + first.getStringValue(), first.getStringValue().equals("ddddd"));
			LangUtils.clearDir(file);
			assertTrue(DataScooter.getDefault().count(ContextTestClassInt.class) == TESTCOUNT);
			backup.backup("", file.getPath(), TEST_BACK_BACK, BackupPolicy.NOT_EMPTY_TABLES, true);
			backup.backupToSql("", file.getPath(), TEST_BACK_SQL, BackupPolicy.NOT_EMPTY_TABLES, true);
			DataScooter.getDefault().dropAll(null, true);
			assertTrue(!DataScooter.getDefault().tableExists(ContextTestClassInt.class));
			backup.restore("", file.getPath(), TEST_BACK_BACK, RestorePolicy.ONLY_EXISTS_TABLES, true);
			assertTrue(!DataScooter.getDefault().tableExists(ContextTestClassInt.class));
			try {
				backup.restore("", file.getPath(), TEST_BACK_BACK, RestorePolicy.THROW_IF_NOT_TABLE, true);
				assertTrue(false);
			} catch (Exception e) {
			}
			backup.restore("", file.getPath(), TEST_BACK_BACK, RestorePolicy.TRY_TO_CREATE_SILENT, true);
			assertTrue(DataScooter.getDefault().tableExists(ContextTestClassInt.class));
			assertTrue(DataScooter.getDefault().count(ContextTestClassInt.class) == TESTCOUNT);
			DataScooter.getDefault().dropAll(null, true);
			assertTrue(!DataScooter.getDefault().tableExists(ContextTestClassInt.class));
			backup.restore("", file.getPath(), TEST_BACK_BACK, RestorePolicy.TRY_TO_CREATE, true);
			assertTrue(DataScooter.getDefault().tableExists(ContextTestClassInt.class));
			assertTrue(DataScooter.getDefault().count(ContextTestClassInt.class) == TESTCOUNT);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	   

Here we test generation of context sensitive id - for further uniqueness purposes
		@Test
	public void testContextIdGen() throws EntityNotMappedException, SecurityException, NoSuchMethodException {
		EntityBundle bundle = new EntityBundle(Word.class.getName(), null, "word", false, false, Word.class);
		bundle.setId(BundleFactory.createDefaultId());
		bundle.addPersistAttribute(BundleFactory.createPersist("value", "value", DBType.STRING, 255, 0, true, true, true));
		DSMapper.addBundle(bundle.entity, bundle);
		bundle.setIdGenerator(new ContextIdGenerator(Word.class.getName(), "value"));
		DataScooter.getDefault().save(new Word("many many"));
	}
	   


YourKit is kindly supporting open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products: YourKit Java Profiler and YourKit .NET Profiler