Hibernate Problem siehe einfach nicht den Fehler

Harry05

Grünschnabel
aloha läute,
sehe nicht den Fehler wo ich die Spalte falsch beschreiben sollte.

danke im Voraus

Java:
ERROR: Unknown column 'filefolder0_.profilsBean_id' in 'field list'

Code:
Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
    at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63)
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:69)
    at org.hibernate.loader.Loader.getResultSet(Loader.java:2178)
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1941)
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1903)
    at org.hibernate.loader.Loader.doQuery(Loader.java:948)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:351)
    at org.hibernate.loader.Loader.doList(Loader.java:2702)
    at org.hibernate.loader.Loader.doList(Loader.java:2685)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2517)
    at org.hibernate.loader.Loader.list(Loader.java:2512)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:384)
    at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1490)
    at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445)
    at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414)
    ... 39 more
Caused by: java.sql.SQLSyntaxErrorException: Unknown column 'filefolder0_.profilsBean_id' in 'field list'
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:536)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115)
    at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1983)
    at com.mysql.cj.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1826)
    at com.mysql.cj.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1923)
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:60)
    ... 54 more

Java:
@Entity
@Table(name = "fileFolders_T")
public class FileFolderBean {

    @Id
    @GeneratedValue
    @Column(name = "id")
    private int id;
    @Column(name = "name", length = 15, nullable = true)
    private String name;
    @Column(name = "pagesNumber", length = 254, nullable = true)
    private int pagesNumber;
    @Column(name = "deletedPages", length = 254, nullable = true )
    private int deletedPages;
    @ManyToOne(cascade = CascadeType.ALL)
    private ProfilsBean profilsBean;

    public FileFolderBean( int id, String name, int pagesNumber, int deletedPages, ProfilsBean profilsBean ) {
        this.id = id;
        this.name = name;
        this.pagesNumber = pagesNumber;
        this.deletedPages = deletedPages;
        this.profilsBean = profilsBean;
    }

    public int getId() {
        return id;
    }

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

    public String getName() {
        return name;
    }

    public void setName( String name ) {
        this.name = name;
    }

    public int getPagesNumber() {
        return pagesNumber;
    }

    public void setPagesNumber( int pagesNumber ) {
        this.pagesNumber = pagesNumber;
    }

    public int getDeletedPages() {
        return deletedPages;
    }

    public void setDeletedPages( int deletedPages ) {
        this.deletedPages = deletedPages;
    }

    public ProfilsBean getProfilsBean() {
        return profilsBean;
    }

    public void setProfilsBean( ProfilsBean profilsBean ) {
        this.profilsBean = profilsBean;
    }
}

Java:
@Override
    public List<FileFolderBean> loadAlbumsByProfilsId( int id ) {
        return getSessionFactory().openSession()
                .createQuery("FROM FileFolderBean WHERE profil_id = :id", FileFolderBean.class)
                .setParameter("id", id)
                .list();
    }
 

Anhänge

  • tabelle.PNG
    tabelle.PNG
    8,7 KB · Aufrufe: 1

Bratkartoffel

gebratene Kartoffel
Premium-User
Hi,

müsste es nicht wie folgt lauten?
createQuery("FROM FileFolderBean WHERE profilsBean.id = :id", FileFolderBean.class)

Grüsse,
BK
 

Harry05

Grünschnabel
@Bratkartoffel
leider ist das das noch nicht

brauchst du noch irgend welche andern Information wie Profile Klasse aber ich den mal das sie Läuft da sie funkt ich vermute es ist das File bean
 
Zuletzt bearbeitet:

Harry05

Grünschnabel
@Bratkartoffel ich habe es Gelöst was falsch wahr so wie ich gesagt habe in der Class FileFolderBean

Falsch
Java:
@Entity
@Table(name = "fileFolders_T")
public class FileFolderBean {
    @Id
    @GeneratedValue
    @Column(name = "id")
    private int id;
    @Column(name = "name", length = 15, nullable = true)
    private String name;
    @Column(name = "pagesNumber", length = 254, nullable = true)
    private int pagesNumber;
    @Column(name = "deletedPages", length = 254, nullable = true )
    private int deletedPages;
    @ManyToOne(cascade = CascadeType.ALL)
    [COLOR=#ff0000]private ProfilsBean profilsBean[/COLOR];

Richtig

Java:
@Entity
@Table(name = "fileFolders_T")
public class FileFolderBean {

    @Id
    @GeneratedValue
    @Column(name = "id")
    private int id;
    @Column(name = "name", length = 15, nullable = true)
    private String name;
    @Column(name = "pagesNumber", length = 254, nullable = true)
    private int pagesNumber;
    @Column(name = "deletedPages", length = 254, nullable = true )
    private int deletedPages;
    @ManyToOne(cascade = CascadeType.ALL)
   [COLOR=#80ff00] private ProfilsBean profil;[/COLOR]
 

Neue Beiträge