Skip to content

Commit e60f10f

Browse files
committed
Implement jpa
1 parent 065a13c commit e60f10f

17 files changed

Lines changed: 1472 additions & 13 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"changes":{"crates/vespertide-macro/Cargo.toml":"Patch","crates/vespertide-config/Cargo.toml":"Patch","crates/vespertide-planner/Cargo.toml":"Patch","crates/vespertide-query/Cargo.toml":"Patch","crates/vespertide-loader/Cargo.toml":"Patch","crates/vespertide/Cargo.toml":"Patch","crates/vespertide-naming/Cargo.toml":"Patch","crates/vespertide-cli/Cargo.toml":"Patch","crates/vespertide-core/Cargo.toml":"Patch","crates/vespertide-exporter/Cargo.toml":"Patch"},"note":"Implement jpa","date":"2026-03-24T10:44:57.164009900Z"}

Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/vespertide-cli/src/commands/export.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub enum OrmArg {
1515
Seaorm,
1616
Sqlalchemy,
1717
Sqlmodel,
18+
Jpa,
1819
}
1920

2021
impl From<OrmArg> for Orm {
@@ -23,6 +24,7 @@ impl From<OrmArg> for Orm {
2324
OrmArg::Seaorm => Orm::SeaOrm,
2425
OrmArg::Sqlalchemy => Orm::SqlAlchemy,
2526
OrmArg::Sqlmodel => Orm::SqlModel,
27+
OrmArg::Jpa => Orm::Jpa,
2628
}
2729
}
2830
}
@@ -133,6 +135,7 @@ async fn clean_export_dir(root: &Path, orm: Orm) -> Result<()> {
133135
let ext = match orm {
134136
Orm::SeaOrm => "rs",
135137
Orm::SqlAlchemy | Orm::SqlModel => "py",
138+
Orm::Jpa => "java",
136139
};
137140

138141
clean_dir_recursive(root, ext).await?;
@@ -224,13 +227,32 @@ fn build_output_path(root: &Path, rel_path: &Path, orm: Orm) -> PathBuf {
224227
let ext = match orm {
225228
Orm::SeaOrm => "rs",
226229
Orm::SqlAlchemy | Orm::SqlModel => "py",
230+
Orm::Jpa => "java",
227231
};
228-
out.set_file_name(format!("{}.{}", sanitized, ext));
232+
// Java requires filename to match PascalCase class name
233+
let file_stem = if matches!(orm, Orm::Jpa) {
234+
to_pascal_case(&sanitized)
235+
} else {
236+
sanitized
237+
};
238+
out.set_file_name(format!("{}.{}", file_stem, ext));
229239
}
230240

231241
out
232242
}
233243

244+
fn to_pascal_case(s: &str) -> String {
245+
s.split('_')
246+
.map(|word| {
247+
let mut chars = word.chars();
248+
match chars.next() {
249+
None => String::new(),
250+
Some(first) => first.to_uppercase().chain(chars).collect(),
251+
}
252+
})
253+
.collect()
254+
}
255+
234256
fn sanitize_filename(name: &str) -> String {
235257
name.chars()
236258
.map(|ch| {

0 commit comments

Comments
 (0)