sprng загрузочное приложение - столбец существует в mysql db, но ошибка указана в неизвестном столбце в списке полей - PullRequest
0 голосов
/ 18 октября 2019

Таблица location

| Field         | Type         | Null | Key | Default | Extra          |
+---------------+--------------+------+-----+---------+----------------+
| id            | int(11)      | NO   | PRI | NULL    | auto_increment |
| created_by    | varchar(255) | YES  |     | NULL    |                |
| created_date  | datetime     | YES  |     | NULL    |                |
| enabled       | tinyint(1)   | YES  |     | NULL    |                |
| lat           | double       | YES  |     | NULL    |                |
| lng           | double       | YES  |     | NULL    |                |
+---------------+--------------+------+-----+---------+----------------+


@MappedSuperclass
public class BaseEntity implements Serializable{

  private static final long serialVersionUID = -7415410969017941320L;

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "id", columnDefinition = "serial")
  private Integer id;

  @CreationTimestamp
  @Column(name="created_date")
  private Instant createdDate;

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

  private Boolean enabled = Boolean.TRUE;

  public BaseEntity() {
  }

  public BaseEntity(Integer id) {
    this.id = id;
  }
 // getter/setter
}

@Entity
@Table(catalog = LogSchema.CATALOG_NAME,name = "location")
public class Location extends BaseEntity {

  private Double lat;
  private Double lng;

  public Location() {
  }

  public Location(Integer id) {
    super(id);
  }
 // getter/setter
}

@Repository
public interface LocationRepository extends CrudRepository<Location, Integer>{
}


@Service
public class LocationServiceImpl{

private LocationRepository locationRepository;

 @Override
  public Location create(LocationDto locationDto) {
    Location location = new Location();

    location.setLat(locationDto.getLat());
    location.setLng(locationDto.getLng());

    locationRepository.save(location);

    return location;
  }
  }

Application.properties
spring.datasource.url=jdbc:mysql://192.168.1.2:3306/sample?useEncoding=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=root

hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.hibernate.naming.implicit-strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy


[33mActionQueue:281[0;39m Executing identity-insert immediately
[33mSQL:94[0;39m insert into location (created_by, created_date, enabled, lat, lng) values (?, ?, ?, ?, ?)
[33mBasicBinder:65[0;39m binding parameter [1] as [VARCHAR] - [test]
[33mBasicBinder:65[0;39m binding parameter [2] as [TIMESTAMP] - [2019-10-18T10:19:03.352Z]
[33mBasicBinder:65[0;39m binding parameter [3] as [BOOLEAN] - [true]
[33mBasicBinder:65[0;39m binding parameter [4] as [DOUBLE] - [0.0]
[33mBasicBinder:65[0;39m binding parameter [5] as [DOUBLE] - [0.0]
[33mSqlExceptionHelper:126[0;39m could not execute statement [n/a]
java.sql.SQLSyntaxErrorException: Unknown column 'created_by' in 'field list'
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:970)
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1109)
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1057)
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1377)
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:1042)
    at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
    at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)



The column 'created_by' available with the table  
What is the error here..
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...