Skip to main content
This revision made November 18, 2010 06:41, by Vladimir Zhukov
« earlier revision revert to this « later revision

Data Utils Library for Java 1.6+

Emsoft-data is an open source data utils library for Java 1.6+. Contains data manager for unified work with any data, base generic domain classes with id, name, description properties, exceptions utility and other. For full detail see api doc or sources.

DataManager example:

DataManager is base interface for implementing working with data. It has type parameter T extends DataManager<T> - is type of external manager, a session that you may to use (see method 'initialize'). DataManager supports following mode of work:

beginWork(); // necesserily
beginTransaction(); // if necessary
commitTransaction(); // if necessary
// or
rollbackTransaction(); // if necessary
endWork(); // necesserily

AbstractDataManager is base implementation of DataManager interface. For example, If you want work with RDBMS, you may inherit your DataManager class from AbstractDataManager and implement еру work with DB via Hibernate (for example). And clients of you DataManager class may not have direct reference to Hibernate, just work via DataManager. Similar implementation, you can see in the JDOManagerClass of emsoft-data-jdo project.

This is example of implementation based on JDODataManager.

public class AddressDataManager extends JDODataManager {
    
    public AddressDataManager() {
        // initialize factory
        JDOFactory.initialize("DB");
    }
    
    public AddressDataManager(JDODataManager dataManager) {
        super(dataManager)
    }
    
    public AddressDataManager(PersistenceManagerFactory factory) {
        super(factory)
    }

    public void saveAddresses(List<Building> buildings) {
        Assert.notNullOrEmpty(buildings, "buildings");
        persistenceManager.makePersistentAll(buildings);
    }

    public List<Locality> getLocalities() {
        return findAll(Locality.class, "name");
    }
    
    public List<District> getDistricts(Locality locality) {
        Assert.notNull(locality, "locality");
        locality = persistenceManager.makePersistent(locality);
        return find(District.class, "locality == :loc", "name", locality);
    }
}

See also emsoft-utils project.

Difference compared to previous revision
return find(District.class, "locality == :loc", "name", locality); } } '''See also [http://java.net/projects/emsoft-utils emsoft-utils] project.'''
 
 
Close
loading
Please Confirm
Close