Hi
(I posted the same message in the Hibernate Users forum yesterday, sorry about that)
I am using Hibernate-Tools to generate a mapping for a SQLServer database. My model contains two tables named Contact and Centre, which both have an int as id. There is also an association-table called Contact_Centre, defined as follows:
Code:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Contact_Centre](
[centreId] [int] NOT NULL,
[contactId] [int] NOT NULL,
[startdate] [smalldatetime] NULL,
[enddate] [smalldatetime] NULL,
CONSTRAINT [PK_Contact_Centre] PRIMARY KEY CLUSTERED
(
[centreId] ASC,
[contactId] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Contact_Centre] WITH NOCHECK ADD CONSTRAINT [FK__Contact_C__centr__4F72AE6C] FOREIGN KEY([centreId])
REFERENCES [dbo].[Centre] ([id])
GO
ALTER TABLE [dbo].[Contact_Centre] NOCHECK CONSTRAINT [FK__Contact_C__centr__4F72AE6C]
GO
ALTER TABLE [dbo].[Contact_Centre] WITH NOCHECK ADD CONSTRAINT [FK__Contact_C__conta__5A846E65] FOREIGN KEY([contactId])
REFERENCES [dbo].[Contact] ([id])
GO
ALTER TABLE [dbo].[Contact_Centre] CHECK CONSTRAINT [FK__Contact_C__conta__5A846E65]
What puzzles me is the fact that the generated ContactCentre class has a constructor with this signature:
Code:
public ContactCentre(ContactCentreId id, Contact contact, Centre centre)
rather than
Code:
public ContactCentre(ContactCentreId id)
which I would expect according to my experience with MySQL (this is why I suspect that using SQLServer has something to do with the issue). It doesn't make much sense to ask for a Contact and a Centre object when a ContactCentreId is already required, does it?
Any help much appreciated.