Can't insert into 'TargetPerEntity' derived entity

Posts   
 
    
JuergenF
User
Posts: 29
Joined: 23-May-2006
# Posted on: 04-Aug-2006 16:13:10   

Hi.

technical stuff: I'm working with the newest (03-aug-2006) LLBLGen, SQL-Server 2005 and build a SelfServicing LBLL.

I have many very simple tables for base-data like titles, countries and such. All have fields like No., Description, and ID (identity column) though are semantically very different, so I'd like to build a TargetPerEntity hierarchy.

So I create a table BaseData(Id IDENTITY PK, Nr int, Description nvarchar(40)) and e.g. a table Title(Id int PK) with a 1:1 relation to Basedata (seems a little empty, but there might be additional fields/FKs later wink )

If I do this, and want to insert a TitleEntity, the generated SQL tries to insert the DEFAULT VALUES into the title-ID, not the ID of the previous inserted base-data.

Since title-ID is PK there is no default, and so the transaction rolls back and throws an error...

What could be wrong here? (probably me wink )

Thanks, Juergen

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 04-Aug-2006 16:55:28   

I don't think you can have a table with only a pk and no other column in llblgen since it results in a wrong query. Try adding another column.

JuergenF
User
Posts: 29
Joined: 23-May-2006
# Posted on: 04-Aug-2006 17:22:21   

Jessynoo wrote:

Try adding another column.

I added a (bogus) nullable column TestId with a relation to table 'Country'. Even if I set TestId to something, the INSERT for the title-table leaves out the Id.

Here is what I can see in Profiler:

declare @p3 int
set @p3=13
exec sp_executesql N'INSERT INTO [Fibu].[dbo].[BaseData] ([LanguageId], [Nr], [Description])  VALUES (@LanguageId, @Nummer, @Description);SELECT @Id_BaseDataEntity=SCOPE_IDENTITY()',
N'@Id_BaseDataEntity int output,@LanguageId int,@Nummer smallint,@Description nvarchar(50)',
@Id_BaseDataEntity=@p3 output,@LanguageId=4,@Nummer=100,@Description=N'Herr'
select @p3

declare @p3 int
set @p3=NULL
exec sp_executesql N'INSERT INTO [Fibu].[dbo].[Titel] ([testid])  VALUES (@Testid);SELECT @Id=SCOPE_IDENTITY()',N'@Id int output,@Testid int',@Id=@p3 output,@Testid=2
select @p3

As you can see in the 2nd INSERT, Titel.Id isn't touched at all...

Thanks, Juergen

JuergenF
User
Posts: 29
Joined: 23-May-2006
# Posted on: 04-Aug-2006 17:27:43   

Bah! I'm an idiot - sorry.

I had a different table structure before, without inheritance. After refreshing the catalog I forgot to uncheck the 'Is Identity' box in LLBLGen...

Sorry, Juergen

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 04-Aug-2006 17:53:40   

Thankfully, it's friday wink

Frans Bouma | Lead developer LLBLGen Pro
benles
User
Posts: 62
Joined: 02-May-2005
# Posted on: 02-Feb-2007 18:07:31   

JuergenF wrote:

Bah! I'm an idiot - sorry.

I had a different table structure before, without inheritance. After refreshing the catalog I forgot to uncheck the 'Is Identity' box in LLBLGen...

Sorry, Juergen

I am having this same problem. I removed the identity specification from the subtype in the db, then refreshed. Shouldn't LLBL refresh this correctly?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 02-Feb-2007 19:21:17   

True, it's a bug in v2.0, We can't fix it in v2.0 as it requires a flag in the entityfield, which is persisted, and this breaks loading a project in an older build of the designer, when the project is saved in a newer build with the fix. It will be fixed in v2.1. (It's already checked in, so with v2.1 the fix is there)

Frans Bouma | Lead developer LLBLGen Pro