Skip to content

Commit

Permalink
Fixed logic error pertaining @onetomany and @manytoone annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Lur1an committed Nov 9, 2022
1 parent 8e7a6e0 commit 8ab95ab
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ ${SQLUtil.debug(pojo)}
<#continue>
<#-- Primary Key statement -->
<#elseif field.annotations.javax_persistence_Id??>
<#assign statements = statements + [SQLUtil.primaryKeyStatement(field)]>
<#assign statements += [SQLUtil.primaryKeyStatement(field)]>
<#-- OneToOne statement -->
<#elseif field.annotations.javax_persistence_OneToOne??>
<#-- Key mapped on other table, skip -->
<#if field.annotations.javax_persistence_OneToOne.mappedBy != "">
<#continue>
</#if>
<#assign statements = statements + [SQLUtil.foreignKeyStatement(field)]>
<#-- OneToMany Foreign Keystatement -->
<#assign statements += [SQLUtil.foreignKeyStatement(field)]>
<#-- Skip OneToMany as it's just a Foreign Key on a different table -->
<#elseif field.annotations.javax_persistence_OneToMany??>
<#assign statements = statements + [SQLUtil.foreignKeyStatement(field)]>
<#elseif field.annotations.javax_persistence_ManyToOne??>
<#-- Skip ManyToOne as it's just a Foreign Key on a different table -->
<#continue>
<#-- ManyToOne: create Foreign Keystatement from the field -->
<#elseif field.annotations.javax_persistence_ManyToOne??>
<#assign statements += [SQLUtil.foreignKeyStatement(field)]>
<#-- TODO: Check if there is a JoinTable specified that should be created. -->
<#elseif field.annotations.javax_persistence_ManyToMany??>
<#-- Check if there is a JoinTable specified.... -->
<#continue>
<#-- Try generating simple SQL statement from field -->
<#else>
<#assign statements += [SQLUtil.basicStatement(field)]>
</#if>
Expand All @@ -38,8 +39,6 @@ CREATE TABLE ${tableName} (
${statement},
</#list>
);
<#-- TODO: parse generated JoinTables (NOT SURE IF NECESSARY!
AS TICKET MAYBE IMPLIES 1 SQL FILE FOR EACH ENTITY.
-->
<#-- TODO: parse generated JoinTables -->
<#list joinTables as tb>
</#list>
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public class SQLTestEntity {
private Long id;

@Column(name = "VALUENAME")
private Integer value;
private Integer integerValue;

@OneToOne(mappedBy = "I_am_mapped!!_and_should_be_skipped!")
@OneToOne
private ReferenceEntity refEntity;

@Enumerated(EnumType.STRING)
@Column(length = 420, name = "YES_EXCACTLY")
@Column(length = 420, name = "ENUM_TEST_FIELD_NAME_OVERRIDE")
private EnumForTest enumForTest;

private List<ReferenceEntity> referenceEntities;
Expand All @@ -30,17 +30,16 @@ public void setId(Long id) {
this.id = id;
}

public Integer getValue() {
return value;
public Integer getIntegerValue() {
return integerValue;
}


public void setValue(Integer value) {
this.value = value;
public void setIntegerValue(Integer value) {
this.integerValue = value;
}

@OneToMany
@JoinColumn(name = "reference_entity_id", unique = true, nullable = false)
@OneToMany(mappedBy = "I_SHALL_BE_SKIPPED")
public List<ReferenceEntity> getReferenceEntities() {
return referenceEntities;
}
Expand Down

0 comments on commit 8ab95ab

Please sign in to comment.