Skip to content

Add entities using the JDL model admin #4

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

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
21 changes: 21 additions & 0 deletions .jhipster/Bet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "Bet",
"fields": [
{
"fieldName": "chips",
"fieldType": "Integer"
}
],
"relationships": [],
"changelogDate": "20200329101300",
"entityTableName": "bet",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"clientRootFolder": "",
"applications": "*"
}
28 changes: 28 additions & 0 deletions .jhipster/Game.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "Game",
"fields": [
{
"fieldName": "name",
"fieldType": "String"
}
],
"relationships": [
{
"relationshipType": "one-to-many",
"otherEntityName": "gameCommission",
"otherEntityRelationshipName": "game",
"relationshipName": "gameCommission"
}
],
"changelogDate": "20200329101200",
"entityTableName": "game",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"clientRootFolder": "",
"applications": "*"
}
36 changes: 36 additions & 0 deletions .jhipster/GameCommission.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "GameCommission",
"fields": [
{
"fieldName": "commission",
"fieldType": "Integer"
}
],
"relationships": [
{
"relationshipType": "many-to-one",
"otherEntityName": "gameUser",
"otherEntityRelationshipName": "commission",
"relationshipName": "gameUser",
"otherEntityField": "id"
},
{
"relationshipType": "many-to-one",
"otherEntityName": "game",
"otherEntityRelationshipName": "gameCommission",
"relationshipName": "game",
"otherEntityField": "id"
}
],
"changelogDate": "20200329101100",
"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": "20200329101000",
"entityTableName": "game_user",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"clientRootFolder": "",
"applications": "*"
}
24 changes: 24 additions & 0 deletions .jhipster/Hand.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Hand",
"fields": [],
"relationships": [
{
"relationshipType": "many-to-one",
"otherEntityName": "game",
"otherEntityRelationshipName": "hand",
"relationshipName": "game",
"otherEntityField": "id"
}
],
"changelogDate": "20200329101400",
"entityTableName": "hand",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"clientRootFolder": "",
"applications": "*"
}
29 changes: 29 additions & 0 deletions admin.jh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
entity GameUser {
username String
password String
}

entity GameCommission {
commission Integer
}

entity Game {
name String
}

entity Bet {
chips Integer
}

entity Hand {

}

relationship ManyToOne {
Hand{game} to Game
}

relationship OneToMany {
GameUser{commission} to GameCommission
Game to GameCommission{game}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ 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.Game.class.getName());
createCache(cm, com.mycompany.myapp.domain.Game.class.getName() + ".gameCommissions");
createCache(cm, com.mycompany.myapp.domain.Bet.class.getName());
createCache(cm, com.mycompany.myapp.domain.Hand.class.getName());
// jhipster-needle-ehcache-add-entry
};
}
Expand Down
74 changes: 74 additions & 0 deletions src/main/java/com/mycompany/myapp/domain/Bet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.mycompany.myapp.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;

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

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

private static final long serialVersionUID = 1L;

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

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

// 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 getChips() {
return chips;
}

public Bet chips(Integer chips) {
this.chips = chips;
return this;
}

public void setChips(Integer chips) {
this.chips = chips;
}
// 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 Bet)) {
return false;
}
return id != null && id.equals(((Bet) o).id);
}

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

@Override
public String toString() {
return "Bet{" +
"id=" + getId() +
", chips=" + getChips() +
"}";
}
}
105 changes: 105 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,105 @@
package com.mycompany.myapp.domain;

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 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;

@OneToMany(mappedBy = "game")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<GameCommission> gameCommissions = new HashSet<>();

// 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 Set<GameCommission> getGameCommissions() {
return gameCommissions;
}

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

public Game addGameCommission(GameCommission gameCommission) {
this.gameCommissions.add(gameCommission);
gameCommission.setGame(this);
return this;
}

public Game removeGameCommission(GameCommission gameCommission) {
this.gameCommissions.remove(gameCommission);
gameCommission.setGame(null);
return this;
}

public void setGameCommissions(Set<GameCommission> gameCommissions) {
this.gameCommissions = gameCommissions;
}
// 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() + "'" +
"}";
}
}
Loading