2

We are developing e-Commerce application,in which we want to implement Human Readable Order ID (OD40627056751) for order conformation from our side.we are using java 1.6 and Strus 2.x and mysql 5.5, Please help me out from this issue, Thanks in Advance.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
zameer
  • 471
  • 1
  • 5
  • 15
  • Do you want globally unique id, or unique for your database only. – Jatinder Kumar Sep 19 '14 at 05:02
  • I want globally,because the same unique id i will send to my customer to check their order status.It has to generate and it need to travel to client side for further information of the order – zameer Sep 19 '14 at 05:10
  • See this: http://stackoverflow.com/questions/9543715/generating-human-readable-usable-short-but-unique-ids – Augusto Oct 08 '15 at 12:44
  • 1
    Possible duplicate of [How to create user friendly unique IDs, UUIDs or other unique identifiers in Java](http://stackoverflow.com/questions/4666647/how-to-create-user-friendly-unique-ids-uuids-or-other-unique-identifiers-in-jav) – Mahesh Khond Oct 25 '16 at 16:01
  • @ÁlvaroGonzález I cleaned up my old comments, since they are obsolete now :). – Tom Oct 25 '16 at 16:12
  • @JohnRiddick I'm very pleased to see that you flagged the question as a duplicate, instead of linking it in an answer. Thank you :). – Tom Oct 25 '16 at 16:14
  • 1
    @Tom I was unaware of flagging the question as a duplicate. Thanks to you :) – Mahesh Khond Oct 25 '16 at 16:27

1 Answers1

0

You can use your primary key number with some prefix.

If it is just order number on one site. it does not have to be globally unique, it should be unique order number. And your order table primary key itself is unique.

the order number can be: OD0000000001, OD0000000002, ...., OD0000003333

Jatinder Kumar
  • 503
  • 6
  • 17
  • But what about the case in which an entity has been created but not yet persisted (and, therefore, has not been assigned a primary key)? – scottb Oct 25 '16 at 15:21