Skip to content

Commit

Permalink
manifold-sql changes
Browse files Browse the repository at this point in the history
- change Entity#delete(boolean) to Entity#delete()/undelete()
  • Loading branch information
rsmckinney committed Nov 18, 2023
1 parent 0726b60 commit a41a0f9
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void testDelete() throws SQLException

long countryId = hi.getCountryId();

hi.delete( true );
hi.delete();
txScope.commit();
Country fetchHi = Country.fetch( txScope, countryId );
assertNull( fetchHi );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void testDelete() throws SQLException

long countryId = hi.getCountryId();

hi.delete( true );
hi.delete();
H2Sakila.commit();
Country readHi = Country.fetch( countryId );
assertNull( readHi );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void testDelete() throws SQLException

int countryId = hi.getCountryId();

hi.delete( true );
hi.delete();
txScope.commit();
Country readHi = Country.fetch( txScope, countryId );
assertNull( readHi );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void testDelete() throws SQLException

int countryId = hi.getCountryId();

hi.delete( true );
hi.delete();
txScope.commit();
Country readHi = Country.fetch( txScope, countryId );
assertNull( readHi );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void testDelete() throws SQLException

BigDecimal countryId = hi.getCountryId();

hi.delete( true );
hi.delete();
txScope.commit();
Country readHi = Country.fetch( txScope, countryId );
assertNull( readHi );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void testDelete() throws SQLException

int countryId = hi.getCountryId();

hi.delete( true );
hi.delete();
txScope.commit();
Country readHi = Country.fetch( txScope, countryId );
assertNull( readHi );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void testDelete() throws SQLException

int countryId = hi.getCountryId();

hi.delete( true );
hi.delete();
txScope.commit();
Country readHi = Country.fetch( txScope, countryId );
assertNull( readHi );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"url": "jdbc:postgresql://localhost:5432/sakila?user=postgres&password=password",
"url": "jdbc:postgresql://localhost:5432/sakila",
"user": "postgres",
"password": "password",
"schemaPackage": "manifold.sql.schema.simple.postgres",

"dbDdl": "samples/ddl/postgres-sakila-ddl.sql"
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public interface DbConfig
/** (Optional) The qualified name of the base class to be used for generated schema table classes */
String getCustomBaseClass();

/** (Optional) Return true if using the database and driver in-process (in-memory) e.g., jdbc:h2:mem or jdbc:sqlite::memory:. */
/** (Optional) true if using the database and driver in-process (in-memory) e.g., jdbc:h2:mem or jdbc:sqlite::memory:. */
boolean isInMemory();

/** Returns the build URL if provided, otherwise the runtime URL */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void addTableInterfaces( SchemaTable table, SrcLinkedClass enclosingType
addEntityClass( srcClass );
addCreateMethods( srcClass, table );
addReadMethods( srcClass, table );
addDeleteMethod( srcClass );
addDeleteMethods( srcClass );
addBuilderType( srcClass, table );
addBuilderMethod( srcClass, table );
addTableInfoMethod( srcClass, table );
Expand Down Expand Up @@ -1098,14 +1098,19 @@ private static void addParameters( AbstractSrcMethod method, List<SchemaColumn>
}
}

private void addDeleteMethod( SrcLinkedClass srcClass )
private void addDeleteMethods( SrcLinkedClass srcClass )
{
SrcMethod method = new SrcMethod( srcClass )
SrcMethod delete = new SrcMethod( srcClass )
.modifiers( Flags.DEFAULT )
.name( "delete" )
.addParam( "delete", boolean.class );
method.body( "((OperableTxBindings)getBindings()).setDelete(delete);" );
srcClass.addMethod( method );
.name( "delete" );
delete.body( "((OperableTxBindings)getBindings()).setDelete(true);" );
srcClass.addMethod( delete );

SrcMethod undelete = new SrcMethod( srcClass )
.modifiers( Flags.DEFAULT )
.name( "undelete" );
undelete.body( "((OperableTxBindings)getBindings()).setDelete(false);" );
srcClass.addMethod( undelete );
}

private void addOneToManyMethods( SchemaTable table, SrcLinkedClass srcClass )
Expand Down

0 comments on commit a41a0f9

Please sign in to comment.