Код: Выделить всё
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "evolutions")
@IdClass(value = EvolutionPkey.class)
public class Evolution {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "pokemon_id")
private int pokemonId;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "form_id")
private int formId;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "next_pokemon_id")
private int nextPokemonId;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "next_form_id")
private int nextFormId;
@Column(nullable = false)
private int stage;
@ManyToOne
@JoinColumn(name = "pokemon_id", referencedColumnName = "pokemon_id")
private Pokemon pokemon;
}
@Data
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class EvolutionPkey implements Serializable{
public int pokemonId;
public int formId;
public int nextPokemonId;
public int nextFormId;
}
public class Pokemon {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "pokemon_id")
private int pokemonId;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "form_id")
private int formId;
・・・・
@OneToMany(mappedBy = "pokemon", cascade=CascadeType.ALL)
private List evolutions;
}
Код: Выделить всё
@Autowired
private PokemonRepository pokemonRepository;
pokemonRepository.findByPokemonId(pokemonId)
Код: Выделить всё
public interface PokemonRepository extends JpaRepository
, JpaSpecificationExecutor {
public Optional findByPokemonId(int pokemonId);
}
Код: Выделить всё
Resolved [java.lang.NullPointerException: Cannot invoke "org.hibernate.metamodel.mapping.AttributeMapping.getStateArrayPosition()" because the return value of "org.hibernate.persister.entity.AbstractEntityPersister.findAttributeMapping(String)" is null]
Спасибо!
я попробовал несколько другие способы письма, но это никогда не работало...
Подробнее здесь: https://stackoverflow.com/questions/781 ... tity-class
Мобильная версия