Skip to content

Commit 9a19781

Browse files
committed
Added Claude guidelines and GitHub actions workflow
1 parent 730c361 commit 9a19781

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK 14
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: '14'
21+
distribution: 'temurin'
22+
23+
- name: Cache Maven dependencies
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.m2
27+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
28+
restore-keys: ${{ runner.os }}-m2
29+
30+
- name: Run tests
31+
run: mvn clean test
32+
33+
- name: Generate test report
34+
uses: dorny/test-reporter@v1
35+
if: success() || failure()
36+
with:
37+
name: Maven Tests
38+
path: target/surefire-reports/*.xml
39+
reporter: java-junit

CLAUDE.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a demonstration project for Hibernate Extended Bytecode Enhancement, accompanying the Medium article "Hibernate Extended Bytecode Enhancement". The project shows how Hibernate's bytecode enhancement can automatically detect field changes even when they occur outside of setter methods.
8+
9+
## Build System & Commands
10+
11+
This is a Maven-based Java project using Java 14.
12+
13+
### Essential Commands
14+
- **Build**: `mvn clean compile`
15+
- **Run tests**: `mvn test`
16+
- **Run single test**: `mvn test -Dtest=ExtendedEnhancementTest`
17+
- **Clean**: `mvn clean`
18+
19+
### Dependencies
20+
- Hibernate Core 5.6.15.Final
21+
- H2 Database 2.3.232 (for testing)
22+
- JUnit Jupiter 5.13.4 (for testing)
23+
24+
## Architecture
25+
26+
### Core Components
27+
28+
The project demonstrates Hibernate's extended enhancement feature through:
29+
30+
1. **Cat.java** (`src/main/java/com/forketyfork/hibernate/Cat.java`): JPA entity with:
31+
- Standard getter/setter methods
32+
- `myCustomMethodToChangeData()` that directly modifies the `name` field
33+
34+
2. **SneakyCatService.java** (`src/main/java/com/forketyfork/hibernate/SneakyCatService.java`): Service that directly accesses entity fields bypassing setters via `cat.name = "Buddy"`
35+
36+
3. **ExtendedEnhancementTest.java** (`src/test/java/com/forketyfork/hibernate/ExtendedEnhancementTest.java`): Integration test demonstrating that Hibernate can detect changes made through:
37+
- Custom methods that modify fields directly
38+
- External services accessing package-private fields
39+
40+
### Hibernate Enhancement Configuration
41+
42+
The Maven build uses `hibernate-enhance-maven-plugin` with:
43+
- `enableDirtyTracking=true`: Tracks which fields have been modified
44+
- `enableExtendedEnhancement=true`: Detects field changes even when setters aren't used
45+
- Version 6.6.22.Final (newer than core Hibernate for enhanced features)
46+
47+
### Test Database Setup
48+
49+
Tests use H2 in-memory database with Hibernate configured for:
50+
- Auto-create schema (`hibernate.hbm2ddl.auto=create-drop`)
51+
- SQL logging enabled (`hibernate.show_sql=true`)
52+
53+
The test verifies that field modifications are properly persisted regardless of how they're made, demonstrating the power of extended bytecode enhancement.

0 commit comments

Comments
 (0)