DEV Community

Guillaume Mary for Codefilarete

Posted on


Stalactite ORM 1.0.0 is out !

After many years of dev, Stalactite ORM is finally released ! It has a brand new approach about persistence :

  • mapping is defined by method references instead of Annotations or XML
  • its fluent API helps you see the complexity of you graph
  • it eagerly fetches your relations to avoid hidden sql queries

Here is a short view of what can be achieved with it :

DataSource dataSource = ... // use whatever JDBC DataSource you want
PersistenceContext persistenceContext = new PersistenceContext(dataSource, new HSQLDBDialect());

EntityPersister<Country, Long> countryPersister = MappingEase.entityBuilder(Country.class, long.class)
    .mapKey(Country::getId, IdentifierPolicy.afterInsert())
    .mapOneToOne(Country::getPresident, MappingEase.entityBuilder(Person.class, long.class)
        .mapKey(Person::getId, IdentifierPolicy.afterInsert())

Country country = new Country(42L);
country.setPresident(new Person(12L));

// you can also map an SQL query to build a projection
List<Car> allCars = persistenceContext.newQuery("select id, model, rgb from Car", Car.class)
    .mapKey(Car::new, "id", long.class)
    .map("model", Car::setModel)
    .map("rgb", Car::setColor, int.class, Color::new)
Enter fullscreen mode Exit fullscreen mode

Give it a try, see documentation here

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git