Skip to content

Lightweight Spring-based library for mapping Java POJO to Database without JPA

Notifications You must be signed in to change notification settings

jtouzy/fastrecord

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

frlogo

FastRecord

Lightweight Spring-based library for mapping Java POJO to Database without JPA.

Install

Maven install

<dependency>
  <groupId>com.jtouzy</groupId>
  <artifactId>fastrecord</artifactId>
  <version>{$fastrecord.version}</version>
</dependency>

Basic example

Entity class :

@Entity
public Event {
    @Id
    private String id;
    private String title;
    // /!\ Getters and setters must be implemented but ignored for demo
}

Usage in program :

@Autowired
Statement statementProcessor;

// Find all events (SELECT event.id, event.title FROM event)
List<Event> events = statementProcessor.queryFrom(Event.class).findAll();
// Insert new event
Event event = new Event();
statementProcessor.insert(event).execute();
// Update event
event = statementProcessor.queryFrom(Event.class).eq("event_id", 1).findOne();
statementProcessor.update(event).execute();
// Delete event
statementProcessor.delete(event).execute();

Repositories example

Repository class :

@Service
public class EventRepository extends BaseSimpleIdRepository<Event,Integer> {
    public EventRepository() {
        super(Event.class);
    }
}

Usage in program :

@Autowired
EventRepository eventRepository;

// Find an event with it's ID using Java8 optionals (SELECT event.id, event.title FROM event where event.id = ?)
Optional<Event> optionalEvent = eventRepository.findById(1);
// Find all events (SELECT event.id, event.title FROM event)
List<Event> events = eventRepository.findAll();

About

Lightweight Spring-based library for mapping Java POJO to Database without JPA

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages