I strongly DESAGREE u. Acording Data Modeling (entity-relation modeling)
there isn't any reason to create an ARTIFICAL IDENTIFIER ATTRIBUTE, if there
is a REAL data that can be used as the identifier.
Otherwise u may designate a artifical identifier. Pupils from Colleges
Applicants use to be an anagrama of letters and numbers (so that make up
ID). I think u guess what I mean.
Gupta,
But, I think it's almost impossible to set Hibernate to generate such ID
in automatic fashion. It's better to generate that ID by your application
and set Hibernate so that. I think that's the simplest way.
Hope helping,
Ice-Man
2008/12/15 Nathan Anderson <[email protected]>
> Just like Oscar stated, it is generally considered a best practice to have
> database primary keys that have no business meaning attached to them. The
> example you provide appears as though it probably should be defined as a
> unique not null column, but not primary key. But even if you change the
> data structure that doesn't solve the problem of auto assigning the "next"
> value to a new record.
>
> The method I have used in the past for situations like this to have a table
> in the database that holds the "next" value. Then update the value database
> either in a transaction from your application, or in a stored procedure used
> to save a new record, or with a trigger on the insert statement.
>
> Hope that helps,
> Nathan
>
>
>
> On Sun, Dec 14, 2008 at 8:51 PM, sudhakargupta <
> [email protected]> wrote:
>
>>
>> Thanks for your reply and i need an id likes the 05-CS-123 so, i need an
>> auto
>> generated string to increment the last number, if the client want to use
>> the
>> assigned then how to mention in model class to assign the @Id value.
>>
>>
>> Sudhakar
>>
>>
>> Oscar Alvarez-2 wrote:
>> >
>> > Hello,
>> >
>> > What's the diference between autogenerated Long key and autogenerated
>> > String
>> > key???, i mean, if the String is autogenerated, it's not better solution
>> a
>> > Long key?, but if the String key is meaningful for the end user, then
>> you
>> > should define assigned strategy and assign it before save.
>> >
>> > Best Regards
>> >
>> >
>> >
>> > 2008/12/13 sudhakargupta <[email protected]>
>> >
>> >>
>> >> Thanks for your reply
>> >>
>> >> Is there any other way to use the auto generator for the string in
>> mysql
>> >> or in any other database
>> >>
>> >> please suggest me for this solution..
>> >>
>> >> Sudhakar..
>> >>
>> >>
>> >>
>> >> mraible wrote:
>> >> >
>> >> > If you're going to use Strings for the primary key, you'll have to
>> use
>> >> > a type of generator that doesn't increment. I've never done this,
>> >> > hopefully someone else on this list can help you.
>> >> >
>> >> > Matt
>> >> >
>> >> > On Fri, Dec 12, 2008 at 5:39 AM, sudhakargupta
>> >> > <[email protected]> wrote:
>> >> >>
>> >> >> Hi Matt...
>> >> >>
>> >> >>
>> >> >> Presently i'm working with the appfuse2 struts.. In one of my table
>> i
>> >> >> need
>> >> >> to use the String as a primarykey and use foreignkey relations with
>> >> this
>> >> >> primarykey.
>> >> >>
>> >> >> i created a model class primary key setters/getters are
>> >> >>
>> >> >>
>> >> >> @Id
>> >> >> private String code;
>> >> >>
>> >> >> private String getCode() {
>> >> >> return this.code;
>> >> >> }
>> >> >>
>> >> >> private void setCode(String code) {
>> >> >> this.code = code;
>> >> >> }
>> >> >>
>> >> >> and after that run the command like mvn appfuse:gen and creates the
>> >> all
>> >> >> the
>> >> >> action classes and the jsp files. after that run the command like
>> mvn
>> >> >> jetty:run, then it shows the errors to create the database and to
>> run
>> >> the
>> >> >> project..
>> >> >>
>> >> >> it shows the errors like primarykey field must be the Long
>> datatype..
>> >> >>
>> >> >> can u please suggest me to create the database through appfuse ..
>> >> >>
>> >> >>
>> >> >> Sudhakar
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/Appfuse2-Struts-problem-tp20974893s2369p20974893.html
>> >> >> Sent from the AppFuse - User mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: [email protected]
>> >> >> For additional commands, e-mail: [email protected]
>> >> >>
>> >> >>
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: [email protected]
>> >> > For additional commands, e-mail: [email protected]
>> >> >
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Appfuse2-Struts-problem-tp20974893s2369p20988292.html
>> >> Sent from the AppFuse - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [email protected]
>> >> For additional commands, e-mail: [email protected]
>> >>
>> >>
>> >
>> >
>> > --
>> > Atentamente
>> > Oscar Alvarez V
>> > (09) 8416 4052
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Appfuse2-Struts-problem-tp20974893s2369p21008315.html
>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>