NHibernate.QueryService icon indicating copy to clipboard operation
NHibernate.QueryService copied to clipboard

Inheritance/Subclassing

Open cchamplin opened this issue 12 years ago • 4 comments

We're trying to utilize your code to leverage inherited objects through a webservice. We are running into a number of problems. Our mapping setup is as follows

<class name="Person" abstract="true" table="People">
    <cache region="People" usage="read-only"/>
    <id name="Id">
      <generator class="identity"/>
    </id>
    <property name="FirstName"/>
    <property name="LastName"/>
      <set name="Addresses" table="Addresses" access="field.camelcase">
          <key column="PersonId"/>
          <one-to-many class="Address"/>
      </set>

    <joined-subclass table="Student" name="Student">
          <key column="PersonId"/>
          <property name="Smer" column="SmerEs"/>
    </joined-subclass>
      <joined-subclass table="Staff" name="Staff">
          <key column="PersonId"/>
          <property name="Mer" column="Larp"/>

      </joined-subclass>
  </class>
        public IQueryable<Student> Student
        {

            get { return ApplyExpansions<Student>(Session.Query<Student>()); }
        }

In our database structure we have the tables Student and Staff related to the People table. The service seems to serve this data fine when we add the IQueryable for Student and Staff to the NHibernateContext. The problem is when trying to add a reference to the webservice through .NET we get errors on meta data.

There was an error downloading 'http://localhost:17104/QueryService.svc/_vti_bin/ListData.svc/$metadata'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://localhost:17104/QueryService.svc'.
The remote server returned an unexpected response: (405) Method Not Allowed.
The remote server returned an error: (405) Method Not Allowed.
If the service is defined in the current solution, try building the solution and adding the service reference again.

cchamplin avatar Dec 18 '12 23:12 cchamplin

Check that you have the latest version of the client tools installed. I know that 5.2 has just been released. That would change the behavior of Add Service Reference to make sure it supported everything that has been released since the tools were originally built. For example, inheritance was not originally supported

PeteGoo avatar Dec 19 '12 00:12 PeteGoo

I've installed the latest client tools, and updated all of the OData, and Data.Services packages on both the service and the client. The problem remains. It appears to be specifically related to the fact that the Person entity has a list type of Address on it. Removing the Addresses collection from the class and from the mapping enables the client to install reference the service again. Any thoughts?

Mediator avatar Dec 19 '12 05:12 Mediator

Does it only happen to subclassed components? We have flattened our entities for historical reasons so I don't see this.

PeteGoo avatar Dec 20 '12 21:12 PeteGoo

Yes it seems limited to subclassed entities.

Mediator avatar Dec 21 '12 00:12 Mediator