Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entities using the JDL model admin #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .jhipster/Game.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "Game",
"fields": [
{
"fieldName": "name",
"fieldType": "String"
}
],
"relationships": [
{
"relationshipType": "many-to-one",
"otherEntityName": "gameCommission",
"otherEntityRelationshipName": "game",
"relationshipName": "gameCommission",
"otherEntityField": "id"
}
],
"changelogDate": "20200328134000",
"entityTableName": "game",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"clientRootFolder": "",
"applications": "*"
}
35 changes: 35 additions & 0 deletions .jhipster/GameCommission.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "GameCommission",
"fields": [
{
"fieldName": "commission",
"fieldType": "Integer"
}
],
"relationships": [
{
"relationshipType": "one-to-many",
"otherEntityName": "game",
"otherEntityRelationshipName": "gameCommission",
"relationshipName": "game"
},
{
"relationshipType": "many-to-one",
"otherEntityName": "gameUser",
"otherEntityRelationshipName": "commission",
"relationshipName": "gameUser",
"otherEntityField": "id"
}
],
"changelogDate": "20200328133900",
"entityTableName": "game_commission",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"clientRootFolder": "",
"applications": "*"
}
32 changes: 32 additions & 0 deletions .jhipster/GameUser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "GameUser",
"fields": [
{
"fieldName": "username",
"fieldType": "String"
},
{
"fieldName": "password",
"fieldType": "String"
}
],
"relationships": [
{
"relationshipType": "one-to-many",
"otherEntityName": "gameCommission",
"otherEntityRelationshipName": "gameUser",
"relationshipName": "commission"
}
],
"changelogDate": "20200328133800",
"entityTableName": "game_user",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"clientRootFolder": "",
"applications": "*"
}
17 changes: 17 additions & 0 deletions admin.jh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
entity GameUser {
username String
password String
}

entity GameCommission {
commission Integer
}

entity Game {
name String
}

relationship OneToMany {
GameUser{commission} to GameCommission
GameCommission{game} to Game
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public JCacheManagerCustomizer cacheManagerCustomizer() {
createCache(cm, com.mycompany.myapp.domain.User.class.getName());
createCache(cm, com.mycompany.myapp.domain.Authority.class.getName());
createCache(cm, com.mycompany.myapp.domain.User.class.getName() + ".authorities");
createCache(cm, com.mycompany.myapp.domain.GameUser.class.getName());
createCache(cm, com.mycompany.myapp.domain.GameUser.class.getName() + ".commissions");
createCache(cm, com.mycompany.myapp.domain.GameCommission.class.getName());
createCache(cm, com.mycompany.myapp.domain.GameCommission.class.getName() + ".games");
createCache(cm, com.mycompany.myapp.domain.Game.class.getName());
// jhipster-needle-ehcache-add-entry
};
}
Expand Down
92 changes: 92 additions & 0 deletions src/main/java/com/mycompany/myapp/domain/Game.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.mycompany.myapp.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;

import java.io.Serializable;
import java.util.Objects;

/**
* A Game.
*/
@Entity
@Table(name = "game")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Game implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "name")
private String name;

@ManyToOne
@JsonIgnoreProperties("games")
private GameCommission gameCommission;

// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public Game name(String name) {
this.name = name;
return this;
}

public void setName(String name) {
this.name = name;
}

public GameCommission getGameCommission() {
return gameCommission;
}

public Game gameCommission(GameCommission gameCommission) {
this.gameCommission = gameCommission;
return this;
}

public void setGameCommission(GameCommission gameCommission) {
this.gameCommission = gameCommission;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Game)) {
return false;
}
return id != null && id.equals(((Game) o).id);
}

@Override
public int hashCode() {
return 31;
}

@Override
public String toString() {
return "Game{" +
"id=" + getId() +
", name='" + getName() + "'" +
"}";
}
}
123 changes: 123 additions & 0 deletions src/main/java/com/mycompany/myapp/domain/GameCommission.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package com.mycompany.myapp.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;

import java.io.Serializable;
import java.util.Objects;
import java.util.HashSet;
import java.util.Set;

/**
* A GameCommission.
*/
@Entity
@Table(name = "game_commission")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class GameCommission implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "commission")
private Integer commission;

@OneToMany(mappedBy = "gameCommission")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Game> games = new HashSet<>();

@ManyToOne
@JsonIgnoreProperties("commissions")
private GameUser gameUser;

// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Integer getCommission() {
return commission;
}

public GameCommission commission(Integer commission) {
this.commission = commission;
return this;
}

public void setCommission(Integer commission) {
this.commission = commission;
}

public Set<Game> getGames() {
return games;
}

public GameCommission games(Set<Game> games) {
this.games = games;
return this;
}

public GameCommission addGame(Game game) {
this.games.add(game);
game.setGameCommission(this);
return this;
}

public GameCommission removeGame(Game game) {
this.games.remove(game);
game.setGameCommission(null);
return this;
}

public void setGames(Set<Game> games) {
this.games = games;
}

public GameUser getGameUser() {
return gameUser;
}

public GameCommission gameUser(GameUser gameUser) {
this.gameUser = gameUser;
return this;
}

public void setGameUser(GameUser gameUser) {
this.gameUser = gameUser;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof GameCommission)) {
return false;
}
return id != null && id.equals(((GameCommission) o).id);
}

@Override
public int hashCode() {
return 31;
}

@Override
public String toString() {
return "GameCommission{" +
"id=" + getId() +
", commission=" + getCommission() +
"}";
}
}
Loading