Skip to content

Commit

Permalink
Merge pull request #23 from chaks7/master
Browse files Browse the repository at this point in the history
Exclude Mapping Columns if they are defined as computed columns in the database schema
  • Loading branch information
bytefish committed Mar 12, 2024
2 parents b4b895b + 38a80f3 commit f36d91b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion JSqlServerBulkInsert/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sqlserver.version>12.4.1.jre11</sqlserver.version>
<sqlserver.version>12.6.1.jre11</sqlserver.version>
</properties>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ public static SchemaMetaData getSchemaMetaData(Connection connection, String sch
List<SchemaMetaData.ColumnInformation> columnInformations = new ArrayList<>();

while (rs.next()) {
SchemaMetaData.ColumnInformation columnInformation = new SchemaMetaData.ColumnInformation(
rs.getString("COLUMN_NAME"),
rs.getInt("ORDINAL_POSITION")
);

columnInformations.add(columnInformation);
if(rs.getString("IS_GENERATEDCOLUMN").equals("NO")) {
SchemaMetaData.ColumnInformation columnInformation = new SchemaMetaData.ColumnInformation(
rs.getString("COLUMN_NAME"),
rs.getInt("ORDINAL_POSITION")
);

columnInformations.add(columnInformation);
}
}

// Make sure they are sorted ascending by Ordinals:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ private boolean createTable() throws SQLException {
" (\n" +
" FirstName NVARCHAR(255),\n" +
" LastName NVARCHAR(255),\n" +
" BirthDate DATE\n" +
" BirthDate DATE,\n" +
" Retirement AS (dateadd(year,(60),BirthDate)) \n" +
" );";

Statement statement = connection.createStatement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class Person {

private LocalDate birthDate;

private LocalDate retiringDate;

public Person() {
}

Expand All @@ -39,4 +41,12 @@ public LocalDate getBirthDate() {
public void setBirthDate(LocalDate birthDate) {
this.birthDate = birthDate;
}

public LocalDate getRetiringDate() {
return retiringDate;
}

public void setRetiringDate(LocalDate retiringDate) {
this.retiringDate = retiringDate;
}
}

0 comments on commit f36d91b

Please sign in to comment.