I have a problem when performing a query in an HQL.
ORM
Persona
#Entity
#Table(name = "persona")
#Inheritance(strategy = InheritanceType.JOINED)
#DynamicUpdate
#SelectBeforeUpdate(value = false)
#SelectBeforeUpdate(value = false)
#NamedQueries({
#NamedQuery(name = "PersonasByRfc", query = "FROM Persona p WHERE p.rfc = :rfc "),
#NamedQuery(name = "PersonasPorTipoPersona", query = "FROM Persona p WHERE p.tipoPersona = :tipoPersona "),
#NamedQuery(name = "PersonaByClienteId", query = " SELECT c.persona FROM Cliente c WHERE c.clienteId = :clienteId "),
#NamedQuery(name = "PersonaMoralActiva", query = "SELECT c.persona FROM Cliente c WHERE c.persona.regimenFiscal = 'MORAL' AND c.estatus = 'ACTIVO' ")
})
public class Persona extends CommonBusinessProperties {
private static final long serialVersionUID = 2846894501470704239L;
private Long personaId;
private CatTipoPersona tipoPersona;
private String descripcionTipoPersona;
private String nombres;
private String apellidoMaterno;
private String apellidoPaterno;
private RegimenFiscal regimenFiscal;
private Nacionalidad nacionalidad;
private String rfc;
private String curp;
private Genero genero;
private Date fechaNacimiento;
private Boolean esCliente;
private Boolean esContratante;
private Boolean esPagador;
private Boolean esMontoPagar;
private BigDecimal montoPagar;
private Boolean esPorcentajePagar;
private String porcentajePagar;
private String origenPersona;
private String parentesco;
private Parentesco tranParentesco;
private Cliente cliente;
private ExpedientePersona expedientePersona;
private List<Domicilio> domicilios = new ArrayList<>(0);
private List<Telefono> telefonos = new ArrayList<>(0);
private List<Correo> correos = new ArrayList<>(0);
/**
* Constructor <br>
* Crea una nueva instancia de Persona. <br>
*
* #author Orlando Adrián Ramos Galván (oramos#legosoft.com.mx, orlandoa.ramos#outlook.com)<br>
*/
public Persona() {
super();
}
/**
* Constructor <br>
* Crea una nueva instancia de Persona. <br>
*
* #param personaId
* #author Orlando Adrián Ramos Galván (oramos#legosoft.com.mx, orlandoa.ramos#outlook.com)<br>
*/
public Persona(Long personaId) {
super();
this.personaId = personaId;
}
/**
* Constructor <br>
* Crea una nueva instancia de Persona. <br>
*
* #param personaBuilder
* #author Orlando Adrián Ramos Galván (oramos#legosoft.com.mx, orlandoa.ramos#outlook.com)<br>
*/
public Persona(PersonaBuilder personaBuilder) {
this.tipoPersona = personaBuilder.getTipoPersona();
this.descripcionTipoPersona = personaBuilder.getDescripcionTipoPersona();
this.nombres = personaBuilder.getNombresORazonSocial();
this.apellidoMaterno = personaBuilder.getApellidoMaterno();
this.apellidoPaterno = personaBuilder.getApellidoPaterno();
this.setRegimenFiscal(personaBuilder.getRegimenFiscal());
this.setNacionalidad(personaBuilder.getNacionalidad());
this.setRfc(personaBuilder.getRfc());
this.curp = personaBuilder.getCurp();
this.genero = personaBuilder.getGenero();
this.fechaNacimiento = personaBuilder.getFechaNacimiento();
this.esCliente = personaBuilder.getEsCliente();
this.esContratante = personaBuilder.getEsContratante();
this.esPagador = personaBuilder.getEsPagador();
this.esMontoPagar = personaBuilder.getEsMontoPagar();
this.montoPagar = personaBuilder.getMontoPagar();
this.esPorcentajePagar = personaBuilder.getEsPorcentajePagar();
this.porcentajePagar = personaBuilder.getPorcentajePagar();
this.domicilios = personaBuilder.getDomicilios();
this.telefonos = personaBuilder.getTelefonos();
this.correos = personaBuilder.getCorreos();
}
#Id
#GeneratedValue(strategy = IDENTITY)
#Column(name = "persona_id", unique = true, nullable = false, updatable = false)
public Long getPersonaId() {
return this.personaId;
}
public void setPersonaId(Long personaId) {
this.personaId = personaId;
}
#ManyToOne(fetch = FetchType.EAGER, targetEntity = CatTipoPersona.class)
#JoinColumn(name = "tipo_persona_id")
#Fetch(FetchMode.SELECT)
public CatTipoPersona getTipoPersona() {
return this.tipoPersona;
}
public void setTipoPersona(CatTipoPersona tipoPersona) {
this.tipoPersona = tipoPersona;
}
#Column(name = "tipo_persona", length = 50)
public String getDescripcionTipoPersona() {
return this.descripcionTipoPersona;
}
public void setDescripcionTipoPersona(String tipoPersona) {
this.descripcionTipoPersona = tipoPersona;
}
#Column(name = "origen_persona", length = 50)
public String getOrigenPersona() {
return this.origenPersona;
}
#Column(name = "nombres", length = 100)
public String getNombresORazonSocial() {
return this.nombres;
}
public void setNombresORazonSocial(String nombres) {
this.nombres = nombres;
}
#Column(name = "apellido_materno", length = 100)
public String getApellidoMaterno() {
return this.apellidoMaterno;
}
public void setApellidoMaterno(String apellidoMaterno) {
this.apellidoMaterno = apellidoMaterno;
}
#Column(name = "apellido_paterno", length = 100)
public String getApellidoPaterno() {
return this.apellidoPaterno;
}
public void setApellidoPaterno(String apellidoPaterno) {
this.apellidoPaterno = apellidoPaterno;
}
#Transient
public String getNombreCompleto() {
return this.nombres + " " + this.apellidoMaterno + " " + this.apellidoPaterno;
}
#Column(name = "regimen_fiscal", length = 100)
#Enumerated(EnumType.STRING)
public RegimenFiscal getRegimenFiscal() {
return this.regimenFiscal;
}
public void setRegimenFiscal(RegimenFiscal regimenFiscal) {
this.regimenFiscal = regimenFiscal;
}
#Column(name = "nacionalidad", length = 100)
#Enumerated(EnumType.STRING)
public Nacionalidad getNacionalidad() {
return this.nacionalidad;
}
public void setNacionalidad(Nacionalidad nacionalidad) {
this.nacionalidad = nacionalidad;
}
#Column(name = "rfc", length = 13)
public String getRfc() {
return this.rfc;
}
public void setRfc(String rfc) {
this.rfc = rfc;
}
#Column(name = "curp", length = 45)
public String getCurp() {
return this.curp;
}
public void setCurp(String curp) {
this.curp = curp;
}
#Column(name = "genero", length = 1)
#Convert(converter = GeneroConverter.class)
public Genero getGenero() {
return this.genero;
}
public void setGenero(Genero genero) {
this.genero = genero;
}
#Temporal(TemporalType.DATE)
#Column(name = "fecha_nacimiento", length = 10)
public Date getFechaNacimiento() {
return this.fechaNacimiento;
}
public void setFechaNacimiento(Date fechaNacimiento) {
this.fechaNacimiento = fechaNacimiento;
}
#Column(name = "es_cliente")
public Boolean isCliente() {
return this.esCliente;
}
public void setIsCliente(Boolean esCliente) {
this.esCliente = esCliente;
}
#Column(name = "es_contratante")
public Boolean esContratante() {
return this.esContratante;
}
public void setEsContratante(Boolean esContratante) {
this.esContratante = esContratante;
}
#Column(name = "es_pagador")
public Boolean isEsPagador() {
return this.esPagador;
}
public void setEsPagador(Boolean esPagador) {
this.esPagador = esPagador;
}
#Column(name = "es_monto_pagar")
public Boolean getEsMontoPagar() {
return this.esMontoPagar;
}
public void setEsMontoPagar(Boolean esMontoPagar) {
this.esMontoPagar = esMontoPagar;
}
#Column(name = "monto_pagar", precision = 16, scale = 4)
public BigDecimal getMontoPagar() {
return this.montoPagar;
}
public void setMontoPagar(BigDecimal montoPagar) {
this.montoPagar = montoPagar;
}
#Column(name = "es_porcentaje_pagar")
public Boolean getEsPorcentajePagar() {
return this.esPorcentajePagar;
}
public void setEsPorcentajePagar(Boolean esPorcentajePagar) {
this.esPorcentajePagar = esPorcentajePagar;
}
#Column(name = "porcentaje_pagar", length = 6)
public String getPorcentajePagar() {
return this.porcentajePagar;
}
public void setPorcentajePagar(String porcentajePagar) {
this.porcentajePagar = porcentajePagar;
}
public void setOrigenPersona(String origenPersona) {
this.origenPersona = origenPersona;
}
#OneToOne(fetch = FetchType.EAGER, mappedBy = "persona", targetEntity = ExpedientePersona.class, optional = true)
protected ExpedientePersona getExpedientePersona() {
return this.expedientePersona;
}
protected void setExpedientePersona(ExpedientePersona expedientePersonas) {
this.expedientePersona = expedientePersonas;
}
/**
* #return parentesco
*/
#Column(name = "parentesco", length = 50)
public String getParentesco() {
return parentesco;
}
/**
* #param parentesco
*/
public void setParentesco(String parentesco) {
this.parentesco = parentesco;
}
#OneToOne(fetch = FetchType.EAGER, mappedBy = "persona", targetEntity = Cliente.class, cascade = {
CascadeType.MERGE, CascadeType.DETACH })
#Fetch(FetchMode.SELECT)
public Cliente getCliente() {
return this.cliente;
}
public void setCliente(Cliente cliente) {
this.cliente = cliente;
}
/**
* #return si la persona esta relacionada al contratante y es una familiar este campo idnica que
* parentesco tienen.
*/
#Transient
public Parentesco getTranParentesco() {
return tranParentesco;
}
/**
* #param tranParentesco
*/
public void setTranParentesco(Parentesco tranParentesco) {
this.tranParentesco = tranParentesco;
}
#OneToMany(fetch = FetchType.EAGER, mappedBy = "persona", targetEntity = Domicilio.class, cascade = {
CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH })
#Fetch(FetchMode.SELECT)
#OrderBy
protected List<Domicilio> getDomicilios() {
return this.domicilios;
}
protected void setDomicilios(List<Domicilio> domicilios) {
this.domicilios = domicilios;
}
#OneToMany(fetch = FetchType.EAGER, mappedBy = "persona", targetEntity = Telefono.class, cascade = {
CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH })
#Fetch(FetchMode.SELECT)
#OrderBy
protected List<Telefono> getTelefonos() {
return this.telefonos;
}
protected void setTelefonos(List<Telefono> telefonos) {
this.telefonos = telefonos;
}
#OneToMany(fetch = FetchType.EAGER, mappedBy = "persona", targetEntity = Correo.class, cascade = {
CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH })
#Fetch(FetchMode.SELECT)
#OrderBy
protected List<Correo> getCorreos() {
return this.correos;
}
protected void setCorreos(List<Correo> correos) {
this.correos = correos;
}
}
Related
Hello everyone in advance I have a problem with my one to one connection when I try to log in to the "user" I get this error
what i need is a one to one connection that does not have to be persistent that means a user can have a player but does not have to have it and the other way around
Since in my case the Minecraft server is supposed to fill the player table and the website fills the users so that they can be connected.
2020-07-27 23:06:12,537 DEBUG [http-nio-8080-exec-2] nirvanacw.de.demo.user.UserServiceImpl: --> getUserByEmail email=Test#gmx.de
2020-07-27 23:06:12,550 WARN [http-nio-8080-exec-2] org.hibernate.engine.jdbc.spi.SqlExceptionHelper: SQL Error: 42122, SQLState: 42S22
2020-07-27 23:06:12,550 ERROR [http-nio-8080-exec-2] org.hibernate.engine.jdbc.spi.SqlExceptionHelper: Feld "player0_.player" nicht gefunden
Column "player0_.player" not found; SQL statement:
select player0_.id as id1_2_1_, player0_.banned as banned2_2_1_, player0_.first_joined as first_jo3_2_1_, player0_.ip_address as ip_addre4_2_1_, player0_.last_joined as last_joi5_2_1_, player0_.player as player8_2_1_, player0_.player_name as player_n6_2_1_, player0_.uuid as uuid7_2_1_, user1_.id as id1_3_0_, user1_.active as active2_3_0_, user1_.created as created3_3_0_, user1_.email as email4_3_0_, user1_.first_name as first_na5_3_0_, user1_.last_name as last_nam6_3_0_, user1_.password as password7_3_0_, user1_.reset_password as reset_pa8_3_0_, user1_.roles as roles9_3_0_, user1_.updated as updated10_3_0_, user1_.username as usernam11_3_0_ from player player0_ left outer join user user1_ on player0_.player=user1_.id where player0_.player=? [42122-200]
2020-07-27 23:06:12,558 ERROR [http-nio-8080-exec-2] org.springframework.security.oauth2.provider.endpoint.TokenEndpoint: Handling error: InternalAuthenticationServiceException, could not prepare statement; SQL [select player0_.id as id1_2_1_, player0_.banned as banned2_2_1_, player0_.first_joined as first_jo3_2_1_, player0_.ip_address as ip_addre4_2_1_, player0_.last_joined as last_joi5_2_1_, player0_.player as player8_2_1_, player0_.player_name as player_n6_2_1_, player0_.uuid as uuid7_2_1_, user1_.id as id1_3_0_, user1_.active as active2_3_0_, user1_.created as created3_3_0_, user1_.email as email4_3_0_, user1_.first_name as first_na5_3_0_, user1_.last_name as last_nam6_3_0_, user1_.password as password7_3_0_, user1_.reset_password as reset_pa8_3_0_, user1_.roles as roles9_3_0_, user1_.updated as updated10_3_0_, user1_.username as usernam11_3_0_ from player player0_ left outer join user user1_ on player0_.player=user1_.id where player0_.player=?]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement
org.springframework.security.authentication.InternalAuthenticationServiceException: could not prepare statement; SQL [select player0_.id as id1_2_1_, player0_.banned as banned2_2_1_, player0_.first_joined as first_jo3_2_1_, player0_.ip_address as ip_addre4_2_1_, player0_.last_joined as last_joi5_2_1_, player0_.player as player8_2_1_, player0_.player_name as player_n6_2_1_, player0_.uuid as uuid7_2_1_, user1_.id as id1_3_0_, user1_.active as active2_3_0_, user1_.created as created3_3_0_, user1_.email as email4_3_0_, user1_.first_name as first_na5_3_0_, user1_.last_name as last_nam6_3_0_, user1_.password as password7_3_0_, user1_.reset_password as reset_pa8_3_0_, user1_.roles as roles9_3_0_, user1_.updated as updated10_3_0_, user1_.username as usernam11_3_0_ from player player0_ left outer join user user1_ on player0_.player=user1_.id where player0_.player=?]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement
User Entity :
package nirvanacw.de.demo.user;
import nirvanacw.de.demo.player.Player;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import javax.validation.constraints.Email;
import java.time.ZonedDateTime;
import java.util.Objects;
#Entity
#Table(name = "user")
public class User {
#Id
#GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
#GenericGenerator(name = "native", strategy = "native")
#Column(name = "id", updatable = false, nullable = false)
private Long id;
#Email
#Column(name = "email")
private String email;
#Column(name ="username")
private String username;
#Column(name ="password")
private String password;
#Column(name ="first_name")
private String firstName;
#Column(name ="last_name")
private String lastName;
#OneToOne(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Player player;
#Column(name ="reset_password")
private boolean resetPassword;
#Column(name ="roles")
private String roles;
#Column(name ="active")
private boolean active;
#Column(name = "created")
private ZonedDateTime created;
#Column(name = "updated")
private ZonedDateTime updated;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public boolean isResetPassword() {
return resetPassword;
}
public void setResetPassword(boolean resetPassword) {
this.resetPassword = resetPassword;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRoles() {
return roles;
}
public void setRoles(String roles) {
this.roles = roles;
}
public boolean getActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public Player getPlayer() {
return player;
}
public void setPlayer(Player player) {
this.player = player;
}
#PrePersist
public void onPrePersist() {
this.created = ZonedDateTime.now();
}
#PreUpdate
public void onPreUpdate() {
this.updated = ZonedDateTime.now();
}
#Override
public String toString() {
return "User{" +
"id=" + id +
", email='" + email + '\'' +
", username='" + username + '\'' +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", player=" + player +
", resetPassword=" + resetPassword +
", roles='" + roles + '\'' +
", active=" + active +
", created=" + created +
", updated=" + updated +
'}';
}
#Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
return resetPassword == user.resetPassword &&
active == user.active &&
Objects.equals(id, user.id) &&
Objects.equals(email, user.email) &&
Objects.equals(username, user.username) &&
Objects.equals(password, user.password) &&
Objects.equals(firstName, user.firstName) &&
Objects.equals(lastName, user.lastName) &&
Objects.equals(player, user.player) &&
Objects.equals(roles, user.roles) &&
Objects.equals(created, user.created) &&
Objects.equals(updated, user.updated);
}
#Override
public int hashCode() {
return Objects.hash(id, email, username, password, firstName, lastName, player, resetPassword, roles, active, created, updated);
}
}
Player Entity :
import java.sql.Timestamp;
import java.util.Objects;
import java.util.UUID;
#Entity
#Table(name = "player")
public class Player {
#Id
#GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
#GenericGenerator(name = "native", strategy = "native")
#Column(name = "id", updatable = false, nullable = false)
private Long id;
#Column(name = "uuid")
private UUID uuid;
#OneToOne
#JoinColumn(name = "player")
private User user;
#Length(max = 16)
#Column(name = "player_name")
private String userName;
#Column(name = "banned")
private boolean banned;
#Column(name = "first_joined")
private Timestamp firstJoined;
#Column(name = "last_joined")
private Timestamp lastJoined;
#Column(name = "ip_address")
private String ipAddress;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public UUID getUuid() {
return uuid;
}
public void setUuid(UUID uuid) {
this.uuid = uuid;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public boolean isBanned() {
return banned;
}
public void setBanned(boolean banned) {
this.banned = banned;
}
public Timestamp getFirstJoined() {
return firstJoined;
}
public void setFirstJoined(Timestamp firstJoined) {
this.firstJoined = firstJoined;
}
public Timestamp getLastJoined() {
return lastJoined;
}
public void setLastJoined(Timestamp lastJoined) {
this.lastJoined = lastJoined;
}
public String getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
#Override
public String toString() {
return "Player{" +
"id=" + id +
", uuid=" + uuid +
", user=" + user +
", userName='" + userName + '\'' +
", banned=" + banned +
", firstJoined=" + firstJoined +
", lastJoined=" + lastJoined +
", ipAddress='" + ipAddress + '\'' +
'}';
}
#Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Player player = (Player) o;
return banned == player.banned &&
Objects.equals(id, player.id) &&
Objects.equals(uuid, player.uuid) &&
Objects.equals(user, player.user) &&
Objects.equals(userName, player.userName) &&
Objects.equals(firstJoined, player.firstJoined) &&
Objects.equals(lastJoined, player.lastJoined) &&
Objects.equals(ipAddress, player.ipAddress);
}
#Override
public int hashCode() {
return Objects.hash(id, uuid, user, userName, banned, firstJoined, lastJoined, ipAddress);
}
}
Flyway user :
Create TABLE user(
id bigint NOT NULL AUTO_INCREMENT,
email character varying(256),
username character varying(256),
password character varying(256),
reset_password boolean,
first_name character varying(50),
last_name character varying(50),
gender character varying(10),
player_id character varying(17),
active boolean,
roles character varying(40),
created TIMESTAMP,
updated TIMESTAMP,
CONSTRAINT PK_account_account_id PRIMARY KEY (id)
);
Player Flyway :
CREATE TABLE player(
id bigint NOT NULL AUTO_INCREMENT,
uuid char(36) NOT NULL,
player_name character varying (16),
user_id bigint,
banned boolean,
first_joined timestamp,
last_joined timestamp,
ip_address character varying (15),
CONSTRAINT PK_player_player_id PRIMARY KEY (id),
CONSTRAINT FK_player_user_id_user_id FOREIGN KEY (user_id) REFERENCES user(id)
);
The error is quite clear
Column "player0_.player" not found;
the player table does not have a player column
the error is here:
#OneToOne
#JoinColumn(name = "player")
private User user;
change to:
#OneToOne
#JoinColumn(name = "user_id")
private User user;
It is the column by which the join with user is established.
As a recommendation, there are configuration parameters for the JPA implementation to validate the correct modeling of the entities without the need for queries, find out how to activate it with the implementation you have chosen.
I am planning to join two caches having multiple columns as key. But I am finding difficulty to write join query.
Here is the full code. Please help to write join query using two caches/tables
person value object:
private static class Person implements Serializable {
private PersonKey personKey;
private OrgKey orgKey;
#QuerySqlField
private String firstName;
#QuerySqlField
private String lastName;
#QueryTextField
private String resume;
/** Salary (indexed). */
#QuerySqlField(index = true)
private double salary;
/**
* Custom cache key to guarantee that person is always collocated with
* its organization.
*/
private transient AffinityKey<PersonKey> key;
Person(Organization org, PersonKey key, String firstName, String lastName, double salary, String resume) {
// Generate unique ID for this person.
this.personKey = key;
this.orgKey = org.key;
this.firstName = firstName;
this.lastName = lastName;
this.resume = resume;
this.salary = salary;
}
person key object:
private static class PersonKey implements Serializable {
#QuerySqlField(index = true)
private UUID id;
#QuerySqlField(index = true)
private String location;
public PersonKey(UUID id, String location) {
this.id = id;
this.location = location;
}
}
Organization value object:
private static class Organization implements Serializable {
/** Organization ID (indexed). */
private OrgKey key;
/** Organization name (indexed). */
#QuerySqlField(index = true)
private String name;
public Organization(OrgKey key, String name) {
this.key = key;
this.name = name;
}
organization key class:
private static class OrgKey implements Serializable {
#QuerySqlField(index = true)
private int id;
#QuerySqlField(index = true)
private String location;
private UUID orgId;
public OrgKey(int id, String location, UUID orgId) {
this.id = id;
this.location = location;
this.orgId = orgId;
}
}
Join query:
IgniteCache<AffinityKey<PersonKey>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
String sql = "select * " + "from Persons, Organizations as org " + "where Persons.id = org.orgId";
QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(sql));
Ignite cache creation:
/** Organizations cache name. */
private static final String ORG_CACHE = "Organizations";
/** Persons cache name. */
private static final String PERSON_CACHE = "Persons";
CacheConfiguration<OrgKey, Organization> orgCacheCfg = new CacheConfiguration<>(ORG_CACHE);
orgCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
orgCacheCfg.setIndexedTypes(OrgKey.class, Organization.class);
CacheConfiguration<AffinityKey<PersonKey>, Person> personCacheCfg = new CacheConfiguration<>(PERSON_CACHE);
personCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
personCacheCfg.setIndexedTypes(AffinityKey.class, Person.class);
Please check this simple example, I do join by two fields in keys:
package sql;
import java.util.Arrays;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.query.FieldsQueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.jetbrains.annotations.NotNull;
public class DoubleJoin {
public static final String DEFAULT_CACHE_NAME = "DEFAULT";
public static void main(String[] args) throws InterruptedException {
IgniteConfiguration ignCfg = new IgniteConfiguration();
TcpDiscoverySpi spi = new TcpDiscoverySpi();
TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder();
finder.setAddresses(Arrays.asList("127.0.0.1"));
spi.setIpFinder(finder);
ignCfg.setDiscoverySpi(spi);
Ignite ignite = Ignition.start(ignCfg);
CacheConfiguration cacheCfg = getCacheConfiguration();
final IgniteCache cache = ignite.getOrCreateCache(cacheCfg);
cache.put(new A(1, 2), new AVal(100));
cache.put(new B(1, 2), new BVal(100));
FieldsQueryCursor cursor = cache.query(new SqlFieldsQuery("SELECT * " +
"FROM AVal " +
"INNER JOIN BVal ON AVal.a1=BVal.b1 AND AVal.a2=BVal.b2;"));
for (Object o : cursor) {
System.out.println(o);
}
}
static class A {
#AffinityKeyMapped
#QuerySqlField
int a1;
#QuerySqlField
int a2;
public A(int a1, int a2) {
this.a1 = a1;
this.a2 = a2;
}
}
static class AVal {
#QuerySqlField
int aV;
public AVal(int aV) {
this.aV = aV;
}
}
static class B {
#AffinityKeyMapped
#QuerySqlField
int b1;
#QuerySqlField
int b2;
public B(int b1, int b2) {
this.b1 = b1;
this.b2 = b2;
}
}
static class BVal {
#QuerySqlField
int bV;
public BVal(int bV) {
this.bV = bV;
}
}
#NotNull private static CacheConfiguration<Integer, Integer> getCacheConfiguration() {
CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>();
cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cfg.setName(DEFAULT_CACHE_NAME);
cfg.setIndexedTypes(A.class, AVal.class, B.class, BVal.class);
return cfg;
}
}
I did a small modification to CLASS A, please correct me if I am wrong. I have used affinity key mapper as per the below link.
https://apacheignite.readme.io/docs/affinity-collocation
package com.cache;
import java.util.Arrays;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.affinity.AffinityKeyMapped;
import org.apache.ignite.cache.query.FieldsQueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.jetbrains.annotations.NotNull;
public class DoubleJoin {
public static final String DEFAULT_CACHE_NAME = "DEFAULT";
public static void main(String[] args) throws InterruptedException {
IgniteConfiguration ignCfg = new IgniteConfiguration();
TcpDiscoverySpi spi = new TcpDiscoverySpi();
TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder();
finder.setAddresses(Arrays.asList("127.0.0.1"));
spi.setIpFinder(finder);
ignCfg.setDiscoverySpi(spi);
Ignite ignite = Ignition.start(ignCfg);
CacheConfiguration cacheCfg = getCacheConfiguration();
final IgniteCache cache = ignite.getOrCreateCache(cacheCfg);
cache.put(new A(1, 2), new AVal(100, new A(1, 2)));
cache.put(new A(2, 3), new AVal(200, new A(2, 3)));
cache.put(new A(3, 4), new AVal(300, new A(3, 4)));
cache.put(new B(1, 2), new BVal(200));
FieldsQueryCursor cursor = cache.query(new SqlFieldsQuery("SELECT BVall.b1, BVall.b2, BVall.bV " + "FROM AVal "
+ "INNER JOIN (select * from BVal where BVal.bV = ?) BVall ON AVal.a1=BVall.b1 AND AVal.a2=BVall.b2 ;").setArgs(200));
for (Object o : cursor) {
System.out.println(o);
}
}
static class A {
#QuerySqlField
int a1;
#QuerySqlField
int a2;
#AffinityKeyMapped
int b1;
#AffinityKeyMapped
int b2;
public A(int a1, int a2) {
this.a1 = a1;
this.a2 = a2;
this.b1 = a1;
this.b2 = a2;
}
}
static class AVal {
#QuerySqlField
int aV;
A a;
public AVal(int aV, A a) {
this.aV = aV;
this.a = a;
}
}
static class B {
#QuerySqlField
int b1;
#QuerySqlField
int b2;
public B(int b1, int b2) {
this.b1 = b1;
this.b2 = b2;
}
}
static class BVal {
#QuerySqlField
int bV;
public BVal(int bV) {
this.bV = bV;
}
}
#NotNull
private static CacheConfiguration<Integer, Integer> getCacheConfiguration() {
CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>();
cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cfg.setName(DEFAULT_CACHE_NAME);
cfg.setIndexedTypes(A.class, AVal.class, B.class, BVal.class);
return cfg;
}
}
In the restbucks project, an order has a private list of line items. I can't figure out how this field is exposed via rest api when getting a single order. It has no public getter or anything. Is it the mixins?
#Data, #NoArgsConstructor, #AllArgsConstructor, #EqualsAndHashCode are Lombok annotations, that are used to auto-generate a boilerplate code.
#Data
#Entity
#NoArgsConstructor(force = true)
#AllArgsConstructor
#EqualsAndHashCode(callSuper = false)
public class LineItem extends AbstractEntity {
private final String name;
private final int quantity;
private final Milk milk;
private final Size size;
private final MonetaryAmount price;
public LineItem(String name, MonetaryAmount price) {
this(name, 1, Milk.SEMI, Size.LARGE, price);
}
}
You can compare this code with delomboked one (welcome to Lombok-funs club )):
#Entity
public class LineItem extends AbstractEntity {
private final String name;
private final int quantity;
private final Milk milk;
private final Size size;
private final MonetaryAmount price;
public LineItem(String name, MonetaryAmount price) {
this(name, 1, Milk.SEMI, Size.LARGE, price);
}
public LineItem(String name, int quantity, Milk milk, Size size, MonetaryAmount price) {
this.name = name;
this.quantity = quantity;
this.milk = milk;
this.size = size;
this.price = price;
}
public LineItem() {
this.name = null;
this.quantity = 0;
this.milk = null;
this.size = null;
this.price = null;
}
public String getName() {
return this.name;
}
public int getQuantity() {
return this.quantity;
}
public Milk getMilk() {
return this.milk;
}
public Size getSize() {
return this.size;
}
public MonetaryAmount getPrice() {
return this.price;
}
public String toString() {
return "LineItem(name=" + this.getName() + ", quantity=" + this.getQuantity() + ", milk=" + this.getMilk() + ", size=" + this.getSize() + ", price=" + this.getPrice() + ")";
}
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof LineItem)) return false;
final LineItem other = (LineItem) o;
if (!other.canEqual((Object) this)) return false;
final Object this$name = this.getName();
final Object other$name = other.getName();
if (this$name == null ? other$name != null : !this$name.equals(other$name)) return false;
if (this.getQuantity() != other.getQuantity()) return false;
final Object this$milk = this.getMilk();
final Object other$milk = other.getMilk();
if (this$milk == null ? other$milk != null : !this$milk.equals(other$milk)) return false;
final Object this$size = this.getSize();
final Object other$size = other.getSize();
if (this$size == null ? other$size != null : !this$size.equals(other$size)) return false;
final Object this$price = this.getPrice();
final Object other$price = other.getPrice();
if (this$price == null ? other$price != null : !this$price.equals(other$price)) return false;
return true;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
result = result * PRIME + this.getQuantity();
final Object $milk = this.getMilk();
result = result * PRIME + ($milk == null ? 43 : $milk.hashCode());
final Object $size = this.getSize();
result = result * PRIME + ($size == null ? 43 : $size.hashCode());
final Object $price = this.getPrice();
result = result * PRIME + ($price == null ? 43 : $price.hashCode());
return result;
}
protected boolean canEqual(Object other) {
return other instanceof LineItem;
}
}
My main class code
{
ArrayList<Item> items = new ArrayList<Item>();
Scanner file = new Scanner(kk.class.getResourceAsStream("product.txt"));
while (file.hasNextLine()) {
String[] sp = file.nextLine().split(",");
// extract item number, description, price and type
itemNum = Integer.parseInt(sp[0]);
des = sp[1];
price = Integer.parseInt(sp[2]);
Item objt = new Item(itemNum, des, price); // Creating a new object
items.add(objt); // Adding it to the list
}
System.out.println(items);
}
output I am getting
[dada.Item#4a5d4a62, dada.Item#32be8e12, dada.Item#7c6159c4, dada.Item#5b4c92a7, dada.Item#3040c5,
My item class code
private int itemNum = 0;
private String des = "";
private int price = 0;
public Item(int i, String d, int p) {
itemNum = i;
des = d;
price = p;
}
You're printing the Item reference's address instead of the fields inside your Item object. You have print the fields inside each Item object by looping through them.
Replace this line
System.out.println(items);
with
for(Item i : items)
{
System.out.println(i.getItemNum()+" "+i.getDes()+" "+i.getPrice());
}
Change the class so that you could access your private fields
private int itemNum = 0;
private String des = "";
private int price = 0;
public Item(int i, String d, int p) {
itemNum = i;
des = d;
price = p;
}
public void setItemNum(int itemNum) {
this.itemNum = itemNum;
}
public int getItemNum() {
return itemNum;
}
public void setDes(String des) {
this.des = des;
}
public String getDes() {
return des;
}
public void setPrice(int price) {
this.price = price;
}
public int getPrice() {
return price;
}
I've been working on a new plugin, and when I load it up, it gives me a "NullPointerException" error, and I can't seem to find where it could find an error. Here is the error:
[20:15:45] [Server thread/INFO]: [EntityManager] Enabling EntityManager v3.0.0.4
[20:15:45] [Server thread/INFO]: [0;31;1mEntityManager [0;32;1m3.0.0.4[0;36;1m Enabled![m
[20:15:45] [Server thread/ERROR]: Error occurred while enabling EntityManager v3.0.0.4 (Is it up to date?)
java.lang.NullPointerException
at me.AngryCupcake274.EntityManager.EntityManager.loadConfiguration(EntityManager.java:296) ~[?:?]
at me.AngryCupcake274.EntityManager.EntityManager.onEnable(EntityManager.java:63) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316) ~[spigot.jar:git-Spigot-1649]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332) [spigot.jar:git-Spigot-1649]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:417) [spigot.jar:git-Spigot-1649]
at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugin(CraftServer.java:476) [spigot.jar:git-Spigot-1649]
at org.bukkit.craftbukkit.v1_7_R4.CraftServer.enablePlugins(CraftServer.java:394) [spigot.jar:git-Spigot-1649]
at net.minecraft.server.v1_7_R4.MinecraftServer.n(MinecraftServer.java:360) [spigot.jar:git-Spigot-1649]
at net.minecraft.server.v1_7_R4.MinecraftServer.g(MinecraftServer.java:334) [spigot.jar:git-Spigot-1649]
at net.minecraft.server.v1_7_R4.MinecraftServer.a(MinecraftServer.java:290) [spigot.jar:git-Spigot-1649]
at net.minecraft.server.v1_7_R4.DedicatedServer.init(DedicatedServer.java:210) [spigot.jar:git-Spigot-1649]
at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:458) [spigot.jar:git-Spigot-1649]
at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-Spigot-1649]
package me.AngryCupcake274.EntityManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.*;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
public class EntityManager extends JavaPlugin implements Listener {
RemoveEntities reme;
CommandHandler comh;
CleanEntities cent;
int loopdelay;
String oneminutemessage;
String oneminutecolor;
String threesecondsmessage;
String threesecondscolor;
String twosecondsmessage;
String twosecondscolor;
String onesecondmessage;
String onesecondcolor;
String finalmessage;
String finalcolor;
String oneMinWarn;
String threeSecWarn;
String twoSecWarn;
String oneSecWarn;
String removeInfo;
String[] worldNames;
Server server = Bukkit.getServer();
ConsoleCommandSender console = server.getConsoleSender();
PluginDescriptionFile pdf = this.getDescription();
String pdfEnable = ChatColor.RED + pdf.getName() + " " + ChatColor.GREEN
+ pdf.getVersion() + ChatColor.AQUA + " Enabled!";
String pdfDisable = ChatColor.RED + pdf.getName() + " " + ChatColor.GREEN
+ pdf.getVersion() + ChatColor.DARK_PURPLE + " Enabled!";
Player cleaner;
int counter = 0;
int totalcounter = 0;
#Override
public void onEnable() {
console.sendMessage(pdfEnable);
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
saveDefaultConfig();
loadConfiguration();
scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
#Override
public void run() {
for (int first = 0; first >= 1; first++) {
cleanUp();
}
}
}, 0L, 12000L);
}
#Override
public void onDisable() {
console.sendMessage(pdfDisable);
}
#SuppressWarnings("deprecation")
public void cleanUp() {
// warn
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(oneMinWarn);
}
console.sendMessage(oneMinWarn);
BukkitScheduler warn3 = Bukkit.getServer().getScheduler();
warn3.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(threeSecWarn);
}
console.sendMessage(threeSecWarn);
}
}, 1220L);
BukkitScheduler warn2 = Bukkit.getServer().getScheduler();
warn2.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(twoSecWarn);
}
console.sendMessage(twoSecWarn);
}
}, 1240L);
BukkitScheduler warn1 = Bukkit.getServer().getScheduler();
warn1.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(oneSecWarn);
}
console.sendMessage(oneSecWarn);
}
}, 1260L);
BukkitScheduler doAction = Bukkit.getServer().getScheduler();
doAction.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
reme.removeEntities();
}
}, 1280L);
}
#SuppressWarnings("deprecation")
public void cleanUpCommand() {
// warn
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(threeSecWarn);
}
console.sendMessage(threeSecWarn);
BukkitScheduler warn2c = Bukkit.getServer().getScheduler();
warn2c.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(twoSecWarn);
}
console.sendMessage(twoSecWarn);
}
}, 20L);
BukkitScheduler warn1c = Bukkit.getServer().getScheduler();
warn1c.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(oneSecWarn);
}
console.sendMessage(oneSecWarn);
}
}, 40L);
BukkitScheduler doAction = Bukkit.getServer().getScheduler();
doAction.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(removeInfo);
}
console.sendMessage(removeInfo);
}
}, 60L);
}
public void cleanUpCommand2() {
BukkitScheduler doAction = Bukkit.getServer().getScheduler();
doAction.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
reme.removeEntities();
}
}, 0L);
}
public void loadConfiguration() {
String ltime = "looptime";
String onemmsg = "oneminute.message";
String onemcolor = "oneminute.color";
String threesmsg = "threeseconds.message";
String threescolor = "threeseconds.color";
String twosmsg = "twoseconds.message";
String twoscolor = "twoseconds.color";
String onesmsg = "onesecond.message";
String onescolor = "onesecond.color";
String fmsg = "final.message";
String fcolor = "final.color";
String arrowr = "arrow";
String boatr = "boat";
String itemr = "dropped_item";
String eggr = "egg";
String enderdragonr = "ender_dragon";
String enderpearlr = "ender_pearl";
String endersignalr = "ender_signal";
String xporbr = "experience_orb";
String fireballr = "fireball";
String fireworkr = "firework";
String fishinghookr = "fishing_hook";
String itemframer = "item_frame";
String leashr = "leash_hitch";
String lightningr = "lightning";
String minecartr = "minecart";
String minecartchestr = "minecart_chest";
String minecartcommandr = "minecart_command";
String minecartfurnacer = "minecart_furnace";
String minecarthopperr = "minecart_hopper";
String minecartmobspawnerr = "minecart_mob_spawner";
String minecarttntr = "minecart_tnt";
String paintingr = "painting";
String primedtntr = "primed_tnt";
String sfireballr = "small_fireball";
String snowballr = "snowball";
String splashpotionr = "splash_potion";
String expbottler = "exp_bottle";
String thrownxpbottler = "thrown_exp_bottle";
String witherskullr = "wither_skull";
getConfig().addDefault(ltime, (10 * 60 * 20));
getConfig().addDefault(onemmsg,
"Ground items will be removed in 1 minute!");
getConfig().addDefault(onemcolor, "AQUA");
getConfig().addDefault(threesmsg,
"Ground items will be removed in 3 seconds!");
getConfig().addDefault(threescolor, "DARK_GREEN");
getConfig().addDefault(twosmsg, "2 seconds!");
getConfig().addDefault(twoscolor, "GOLD");
getConfig().addDefault(onesmsg, "1 second!");
getConfig().addDefault(onescolor, "RED");
getConfig().addDefault(fmsg, "Ground items will be removed!");
getConfig().addDefault(fcolor, "DARK_RED");
getConfig().addDefault(arrowr, true);
getConfig().addDefault(boatr, false);
getConfig().addDefault(itemr, true);
getConfig().addDefault(eggr, true);
getConfig().addDefault(enderdragonr, false);
getConfig().addDefault(enderpearlr, true);
getConfig().addDefault(endersignalr, true);
getConfig().addDefault(xporbr, true);
getConfig().addDefault(fireballr, true);
getConfig().addDefault(fireworkr, true);
getConfig().addDefault(fishinghookr, false);
getConfig().addDefault(itemframer, false);
getConfig().addDefault(leashr, false);
getConfig().addDefault(lightningr, true);
getConfig().addDefault(minecartr, false);
getConfig().addDefault(minecartchestr, false);
getConfig().addDefault(minecartcommandr, false);
getConfig().addDefault(minecartfurnacer, false);
getConfig().addDefault(minecarthopperr, false);
getConfig().addDefault(minecartmobspawnerr, false);
getConfig().addDefault(minecarttntr, false);
getConfig().addDefault(paintingr, false);
getConfig().addDefault(primedtntr, true);
getConfig().addDefault(sfireballr, true);
getConfig().addDefault(snowballr, true);
getConfig().addDefault(splashpotionr, true);
getConfig().addDefault(expbottler, true);
getConfig().addDefault(thrownxpbottler, true);
getConfig().addDefault(witherskullr, true);
getConfig().options().copyDefaults(true);
saveConfig();
loopdelay = getConfig().getInt("looptime");
oneminutemessage = getConfig().getString("oneminute.message");
oneminutecolor = getConfig().getString("oneminute.color");
threesecondsmessage = getConfig().getString("threeseconds.message");
threesecondscolor = getConfig().getString("threeseconds.color");
twosecondsmessage = getConfig().getString("twoseconds.message");
twosecondscolor = getConfig().getString("twoseconds.color");
onesecondmessage = getConfig().getString("onesecond.message");
onesecondcolor = getConfig().getString("onesecond.color");
finalmessage = getConfig().getString("final.message");
finalcolor = getConfig().getString("final.color");
oneMinWarn = ChatColor.valueOf(oneminutecolor) + oneminutemessage;
threeSecWarn = ChatColor.valueOf(threesecondscolor)
+ threesecondsmessage;
twoSecWarn = ChatColor.valueOf(twosecondscolor) + twosecondsmessage;
oneSecWarn = ChatColor.valueOf(onesecondcolor) + onesecondmessage;
removeInfo = ChatColor.valueOf(finalcolor) + finalmessage;
reme.arrow = getConfig().getBoolean("arrow");
reme.boat = getConfig().getBoolean("boat");
reme.droppeditem = getConfig().getBoolean("dropped_item");
reme.egg = getConfig().getBoolean("egg");
reme.enderpearl = getConfig().getBoolean("ender_pearl");
reme.endersignal = getConfig().getBoolean("ender_signal");
reme.experienceorb = getConfig().getBoolean("experience_orb");
reme.fireball = getConfig().getBoolean("fireball");
reme.firework = getConfig().getBoolean("firework");
reme.fishinghook = getConfig().getBoolean("fishing_hook");
reme.itemframe = getConfig().getBoolean("item_frame");
reme.leashhitch = getConfig().getBoolean("leash_hitch");
reme.lightning = getConfig().getBoolean("lightning");
reme.minecart = getConfig().getBoolean("minecart");
reme.minecartchest = getConfig().getBoolean("minecart_chest");
reme.minecartcommand = getConfig().getBoolean("minecart_command");
reme.minecartfurnace = getConfig().getBoolean("minecart_furnace");
reme.minecarthopper = getConfig().getBoolean("minecart_hopper");
reme.minecartmobspawner = getConfig().getBoolean("minecart_mob_spawner");
reme.minecarttnt = getConfig().getBoolean("minecart_tnt");
reme.painting = getConfig().getBoolean("painting");
reme.primedtnt = getConfig().getBoolean("primed_tnt");
reme.smallfireball = getConfig().getBoolean("small_fireball");
reme.snowball = getConfig().getBoolean("snowball");
reme.splashpotion = getConfig().getBoolean("splash_potion");
reme.thrownexpbottle = getConfig().getBoolean("exp_bottle");
reme.witherskull = getConfig().getBoolean("wither_skull");
saveDefaultConfig();
}
public void reloadPlugin() {
reloadConfig();
loopdelay = getConfig().getInt("looptime");
oneminutemessage = getConfig().getString("oneminute.message");
oneminutecolor = getConfig().getString("oneminute.color");
threesecondsmessage = getConfig().getString("threeseconds.message");
threesecondscolor = getConfig().getString("threeseconds.color");
twosecondsmessage = getConfig().getString("twoseconds.message");
twosecondscolor = getConfig().getString("twoseconds.color");
onesecondmessage = getConfig().getString("onesecond.message");
onesecondcolor = getConfig().getString("onesecond.color");
finalmessage = getConfig().getString("final.message");
finalcolor = getConfig().getString("final.color");
reme.arrow = getConfig().getBoolean("arrow");
reme.boat = getConfig().getBoolean("boat");
reme.droppeditem = getConfig().getBoolean("dropped_item");
reme.egg = getConfig().getBoolean("egg");
reme.enderpearl = getConfig().getBoolean("ender_pearl");
reme.endersignal = getConfig().getBoolean("ender_signal");
reme.experienceorb = getConfig().getBoolean("experience_orb");
reme.fireball = getConfig().getBoolean("fireball");
reme.firework = getConfig().getBoolean("firework");
reme.fishinghook = getConfig().getBoolean("fishing_hook");
reme.itemframe = getConfig().getBoolean("item_frame");
reme.leashhitch = getConfig().getBoolean("leash_hitch");
reme.lightning = getConfig().getBoolean("lightning");
reme.minecart = getConfig().getBoolean("minecart");
reme.minecartchest = getConfig().getBoolean("minecart_chest");
reme.minecartcommand = getConfig().getBoolean("minecart_command");
reme.minecartfurnace = getConfig().getBoolean("minecart_furnace");
reme.minecarthopper = getConfig().getBoolean("minecart_hopper");
reme.minecartmobspawner = getConfig().getBoolean("minecart_mob_spawner");
reme.minecarttnt = getConfig().getBoolean("minecart_tnt");
reme.painting = getConfig().getBoolean("painting");
reme.primedtnt = getConfig().getBoolean("primed_tnt");
reme.smallfireball = getConfig().getBoolean("small_fireball");
reme.snowball = getConfig().getBoolean("snowball");
reme.splashpotion = getConfig().getBoolean("splash_potion");
reme.thrownexpbottle = getConfig().getBoolean("exp_bottle");
reme.witherskull = getConfig().getBoolean("wither_skull");
getServer().getScheduler().cancelTasks(this);
getServer().getPluginManager().disablePlugin(this);
getServer().getPluginManager().enablePlugin(this);
}
}
me.AngryCupcake274.EntityManager.EntityManager.loadConfiguration(EntityManager.java:296)
The exception is thrown at line 296 of your EntityManager.java file.
reme.arrow = getConfig().getBoolean("arrow");
At this point of time reme is still null and therefore you can't assign arrow.
You should ensure that RemoveEntitites is already instantiated once you call loadConfiguration() in your onEnable() method.
Also see What is a NPE and how do I fix it?.
I did it!
Instead of setting the RemoveEntities variables, I told the RemoveEntities class to find the variables in the EntityManager class.