tags:

views:

134

answers:

3

I need to generate a table without primary key. Its absolutely neccessary that the table dosen't have primary key. Please help.

+5  A: 

It is absolutely necessary for the SubSonic that table contains primary key:)

The following is quoted from the SubSonic docs on conventions:

Primary Keys

If you want to use SubSonic to access your table, you need to have a Primary Key defined for your table. This is good practice in every case and we need it to do certain things with your table. If you don't have a Primary Key defined, your class won't be generated.

If you don't believe us, or if you think this is a silly convention - SubSonic isn't for you.

TheVillageIdiot
But the problem is that a lot of data is repeated and cannot be made primary key. Is there any other solution
Soham Dasgupta
simple just add another identity column and don't use it in your application logic but Subsonic needs this to distinguish the records.
TheVillageIdiot
oh, @stalkerh has also suggested this in his comment!
TheVillageIdiot
+1  A: 

Is there any reason you cannot use something like sequences?

class Something {
     private static final SEQUENCE seq = getDBsequence()

     @id
     private final long id = seq.newNumber();

     private final String whateverData;
}

EDIT:The way I wrote this was kinda dumb because once you reboot the app. you'll get duplicate keys.. You should use a sequence provided by the DB. Sorry about that.

Enno Shioji
+1  A: 

Hi Soham - as Adam pointed out this isn't possible. To be honest I can't think of a situation (outside OLAP) where you can't have a PK. Or perhaps you're stuck in a legacy situation - I can dig that.

What you can do to get around it is, as you pointed out, use our querier tools and then you can send the results ToList<>. Updates should work the same way - not sure about inserts though.

Rob Conery