GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - apache/cayenne: Mirror of Apache Cayenne

BranchesTags
Open more actions menu

Latest commit

 

History

8,547 Commits
8,547 Commits

Folders and files

NameName
Last commit message
Last commit date
.claude-plugin
.claude-plugin
 
 
.claude/rules
.claude/rules
 
 
.github
.github
 
 
ai-plugin
ai-plugin
 
 
build-tools
build-tools
 
 
cayenne-ant
cayenne-ant
 
 
cayenne-assembly
cayenne-assembly
 
 
cayenne-cache-invalidation
cayenne-cache-invalidation
 
 
cayenne-cgen
cayenne-cgen
 
 
cayenne-crypto
cayenne-crypto
 
 
cayenne-dbsync
cayenne-dbsync
 
 
cayenne-di
cayenne-di
 
 
cayenne-gradle-plugin
cayenne-gradle-plugin
 
 
cayenne-jcache
cayenne-jcache
 
 
cayenne-maven-plugin
cayenne-maven-plugin
 
 
cayenne-mcp-server
cayenne-mcp-server
 
 
cayenne-modeler-prefs
cayenne-modeler-prefs
 
 
cayenne-modeler
cayenne-modeler
 
 
cayenne-project-tools
cayenne-project-tools
 
 
cayenne-velocity
cayenne-velocity
 
 
cayenne-wocompat
cayenne-wocompat
 
 
cayenne
cayenne
 
 
docs
docs
 
 
.asf.yaml
.asf.yaml
 
 
.gitignore
.gitignore
 
 
AGENTS.md
AGENTS.md
 
 
CLAUDE.md
CLAUDE.md
 
 
KEYS
KEYS
 
 
README.md
README.md
 
 
RELEASE-NOTES.txt
RELEASE-NOTES.txt
 
 
UPGRADE-4.2-and-older.md
UPGRADE-4.2-and-older.md
 
 
UPGRADE.md
UPGRADE.md
 
 
pom.xml
pom.xml
 
 
rat.sh
rat.sh
 
 

Repository files navigation

Apache Cayenne

Maven Central Build Status

Apache Cayenne is an open source persistence framework for Java. With a wealth of unique and powerful features, Cayenne can address a wide range of persistence needs. Cayenne seamlessly binds one or more database schemas to Java objects, managing atomic commits and rollbacks, SQL generation, joins, sequences, and more.

Cayenne supports database reverse engineering and generation, as well as templated class generation. All of these functions can be controlled through the GUI CayenneModeler app. An entire database schema can be mapped directly to Java objects within minutes, all from the comfort of the GUI-based CayenneModeler.

Cayenne supports numerous other features, including caching, an object query syntax, relationship pre-fetching, on-demand object and relationship faulting, object inheritance, database auto-detection, and generic persistent objects. Cayenne can scale up or down to virtually any project size.

Quick Links

  • Getting Started
  • Documentation
  • Upgrading from Older Cayenne
  • Bug/Feature Tracker

Quick Start

Create XML Mapping

Downloaded Cayenne Modeler from https://cayenne.apache.org/download/, start it and create a Cayenne project.

Include Cayenne in a Project

Maven

<dependencies>
    <dependency>
        <groupId>org.apache.cayenne</groupId>
        <artifactId>cayenne</artifactId>
        <version>5.0-RC1</version>
    </dependency>
</dependencies>

Gradle

implementation 'org.apache.cayenne:cayenne:5.0-RC1'

Create Cayenne Runtime

CayenneRuntime cayenneRuntime = CayenneRuntime.of()
    .addConfig("cayenne-demo.xml")
    .defaultDataNode(CayenneDataSource
             .of("jdbc:mysql://localhost:3306/cayenne_demo")
             .userName("username")
             .password("password")
             .build())
    .build();

Create New Objects

ObjectContext context = cayenneRuntime.newContext();

Artist picasso = context.newObject(Artist.class);
picasso.setName("Pablo Picasso");
picasso.setDateOfBirth(LocalDate.of(1881, 10, 25));

Gallery metropolitan = context.newObject(Gallery.class);
metropolitan.setName("Metropolitan Museum of Art");

Painting girl = context.newObject(Painting.class);
girl.setName("Girl Reading at a Table");

Painting stein = context.newObject(Painting.class);
stein.setName("Gertrude Stein");

picasso.addToPaintings(girl);
picasso.addToPaintings(stein);

girl.setGallery(metropolitan);
stein.setGallery(metropolitan);

context.commitChanges();

Queries

Select Objects

List<Painting> paintings = ObjectSelect.query(Painting.class)
        .where(Painting.ARTIST.dot(Artist.DATE_OF_BIRTH).year().lt(1900))
        .prefetch(Painting.ARTIST.joint())
        .select(context);

Exists Subqueries

long count = ObjectSelect.query(Artist.class)
    .where(Artist.PAINTING_ARRAY.dot(Painting.PAINTING_TITLE).like("painting%").exists())
    .selectCount(context);

Aggregate Functions

List<Object[]> artistAndPaintingCount = ObjectSelect
    .columnQuery(Artist.class, Artist.SELF, Artist.PAINTING_ARRAY.count())
    .where(Artist.ARTIST_NAME.like("a%"))
    .having(Artist.PAINTING_ARRAY.count().lt(5L))
    .orderBy(Artist.PAINTING_ARRAY.count().desc(), Artist.ARTIST_NAME.asc())
    .select(context);

for(Object[] next : artistAndPaintingCount) {
    Artist artist = (Artist)next[0];
    long paintingsCount = (Long)next[1];
    System.out.println(artist.getArtistName() + " has " + paintingsCount + " painting(s)");
}

Raw SQL Queries

// Selecting objects
List<Painting> paintings = SQLSelect
    .query(Painting.class, "SELECT * FROM PAINTING WHERE PAINTING_TITLE LIKE #bind($title)")
    .param("title", "painting%")
    .upperColumnNames()
    .localCache()
    .limit(100)
    .select(context);

// Selecting scalar values
List<String> paintingNames = SQLSelect
    .scalarQuery("SELECT PAINTING_TITLE FROM PAINTING WHERE ESTIMATED_PRICE > #bind($price)", String.class)
    .param("price", 100000)
    .select(context);

// Insert values
int inserted = SQLExec
    .query("INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME) VALUES (#bind($id), #bind($name))")
    .paramsArray(55, "Picasso")
    .update(context);

Collaboration and Support

  • Mailing lists
  • Support
  • Contributing

About

Mirror of Apache Cayenne

Topics

cayennedatabasejavalibrarynetwork-clientnetwork-serverweb-frameworkxml

Resources

Readme

Code of conduct

Code of conduct

Security policy

Security policy
Activity
Custom properties

Stars

349 stars

Watchers

27 watching

Forks

138 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.