Spring mysql: Truncating data (data too long for a column)

I have my Movie Movie:

@Entity
@Table(name="movies")

public class Movie {

    private String genre_ids;
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private long id;
    @Lob
    @Column(length=1000000)
    private String overview;    
    private String release_date;
    private String poster_path;
    private String popularity;
    private String title;

    public Movie() {
        super();
        // TODO Auto-generated constructor stub
    }

    public String getGenre_ids() {
        return genre_ids;
    }

    public void setGenre_ids(String genre_ids) {
        this.genre_ids = genre_ids;
    }

    public long getId() {
        return id;
    }

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

    public String getOverview() {
        return overview;
    }

    public void setOverview(String overview) {
        this.overview = overview;
    }

    public String getRelease_date() {
        return release_date;
    }

    public void setRelease_date(String release_date) {
        this.release_date = release_date;
    }

    public String getPoster_path() {
        return poster_path;
    }

    public void setPoster_path(String poster_path) {
        this.poster_path = poster_path;
    }

    public String getPopularity() {
        return popularity;
    }

    public void setPopularity(String popularity) {
        this.popularity = popularity;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Movie(String genre_ids, long id, String overview, String release_date, String poster_path, String popularity,
            String title) {
        super();
        this.genre_ids = genre_ids;
        this.id = id;
        this.overview = overview;
        this.release_date = release_date;
        this.poster_path = poster_path;
        this.popularity = popularity;
        this.title = title;
    }



}

      

and my controller method:

@RequestMapping(value="/moviesPage",method=RequestMethod.GET)

    public ModelAndView showMoviesPage() {
            ModelAndView model=new ModelAndView("moviePage");
            try {
                JSONObject json=readJsonFromUrl("http://api.themoviedb.org/3/discover/movie?api_key=cbb012e4e7ece74ac4c32a77b00a43eb&sort_by=popularity.desc&page=1");
                JSONArray array=json.getJSONArray("results");
                for(int i=0;i<array.length();i++)
                {
                    JSONObject jsonMovie=array.getJSONObject(i);
                    Movie movie=new Movie(jsonMovie.getString("genre_ids"),jsonMovie.getLong("id"),jsonMovie.getString("overview"),jsonMovie.getString("release_date"),jsonMovie.getString("poster_path"),jsonMovie.getString("popularity"),jsonMovie.getString("title"));
                    movieServiceImpl.createMovie(movie);
                    System.out.println(movie);
                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
             return model; }

      

and I am getting this error:

Servlet.service () for servlet [springDispatcher] in path context [/ web-programming] threw exception [Error processing request; Nested exception is org.springframework.dao.DataIntegrityViolationException: statement cannot be executed; SQL [n / a]; Nested exception - org.hibernate.exception.DataException: Unable to execute statement] with root cause com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data is too long for the "overview" column on line 1

+3


source to share


1 answer


In MySql, change the table if the type is column varchar

then change it to text

. There are many data types in MySql besides text. For example MEDIUM TEXT

, LONGTEXT

etc.

enter image description here



This might be a job for that. I've encountered this error before.

0


source







All Articles