[Closed] could not resolve property

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #259251 Reply


    I have a MySQL View with three string columns.

    When I reverse engineer for Hibernate, I get the following:

        <class name="com.col.hibernate.Ventypereg" table="ventypereg" catalog="test">
            <composite-id name="id" class="com.col.hibernate.VentyperegId">
                <key-property name="vendorName" type="java.lang.String">
                    <column name="VendorName" length="45" />
                <key-property name="catagory" type="java.lang.String">
                    <column name="Catagory" length="45" />
                <key-property name="region" type="java.lang.String">
                    <column name="Region" length="45" />

    And the following (fundemental) classes are created:

    Abstract and concrete Ventypereg.java
    Abstract and concrete VentyperegId.java

    I want to use query string:
    “from Ventypereg as model where model.vendorName like ? AND model.catagory like ? and model. region like ?”

    But I get the following exception:
    org.hibernate.QueryException: could not resolve property: vendorName of: com.col.hibernate.Ventypereg [from com.col.hibernate.Ventypereg as model where model.vendorName like ? AND model.catagory like ? AND model.region = ?]

    Also, when I stub the code and use VentyperegDAO.findByProperty(…) I get the same exception.

    Can someone help here?

    #259269 Reply

    Riyad Kalla

    The problem is that Hibernate cannot manage a table that doesn’t contain a primary key, so what MyEclipse does is uses all the fields of the table to generate a primary key for each record. TO make your life easier, if you add a primary key to this table, and then re-reverse engineer it, your PK will be much simpler than name and the remaining fields will be registered as properties and your query should work fine.

    If you don’t do that, I’m not exactly sure how you only query for a part of a primary key, I don’t think you can.

    #259294 Reply


    That doesn’t work…it’s a reverse engineered MySQL VIEW which doesn’t support a primary key

    #259304 Reply

    Haris Peco


    You can works with view if composite id have unique , non-null values.Tyr with next query :

    from Ventypereg as model where model.id.vendorName like ? AND model.id.catagory like ? and model. id.region like ?

    I am not sure for findByProperty – Please, send use table script (you can generate one with MyEclipse’s ‘generate-> ddl), POJO and DAO classes


    #259311 Reply


    Thanks, that worked. As far as sending the other stuff, it is a view with three (3) columns that are text (Varchar(45)) from three different tables. None of the columns are primary key.

    #259340 Reply

    Haris Peco

    Hibernate request that your id have non-null, unique values.When you have primary key database car about this, but if you use view (or table without PK) , you have to have correct values

    for example, if your view (id values) have this :


    it is invalid (null value) or


    is invalid (non-unique values for id)


    #259345 Reply


    Yes, the view contains unique non-null values. It is working now that I added the “id.” prefix to the attribute in the “model.id.xxx like ?” string.

    Thanks for the help

    #259740 Reply

    Riyad Kalla

    Glad it’s working.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: [Closed] could not resolve property

You must be logged in to post in the forum log in