Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
19 replies
Subscribers
9 subscribers
Views
11784 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Hi, I wonder if I could preset the id of a record to start with 1000 instead of
Will Teoh
over 11 years ago
Hi, I wonder if I could preset the id of a record to start with 1000 instead of 1 when it stores to the database table? Anything to add into the codes below to make that happen?? Thanks
<xsd:annotation>
<xsd:appinfo source="appian.jpa">
@Id
@GeneratedValue
</xsd:appinfo>
</xsd:annotation>...
OriginalPostID-95347
OriginalPostID-95347
Discussion posts and replies are publicly visible
0
Eduardo Fuentes
Appian Employee
over 11 years ago
You need to use a sequence generator:
@SequenceGenerator(name="mysequence", initialValue=1000)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="mysequence")
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
priyaj
over 11 years ago
Hi,
You can also use the below annotation to achieve this for SQL server,
@Column(name = "id",columnDefinition="INTEGER IDENTITY (startingValue,increment Value)",nullable=false)
Example
@Column(name = "id",columnDefinition="INTEGER IDENTITY (1000,1)",nullable=false)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Will Teoh
over 11 years ago
Hi Eduardo, your method doesn't work. It is saying some annotation error?
<xsd:annotation>
<xsd:appinfo source="appian.jpa">
@Id
@SequenceGenerator(name="mysequence", initialValue=1000)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="mysequence")
</xsd:appinfo>
</xsd:annotation>
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Will Teoh
over 11 years ago
The error message: Invalid type mapping annotation found.
A type mapping annotation is invalid: Could not instantiate id generator [entity-name=OPPORTUNITYDETAILSMAINDT191789] (MappingException) (APNX-2-4055-000)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Will Teoh
over 11 years ago
I have used priyaj method, and able to publish the datastore successfully.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Will Teoh
over 11 years ago
priyaj method couldn't work either. It says the id has to be manually set to store into the DB table. =(
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
priyaj
over 11 years ago
We have also faced the same issue when using Write to DataStore Node. Then we tried Query DB Node to insert data to database. It resolved the issue. Hope this helps in your case.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Navajith K
over 11 years ago
you can also store 1000 in a constant and can increment the constant in your process model by using "Increment Constant" node. Hope this helps...
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 11 years ago
does the constraint have to be on the XSD side? if it were me, I'd probably just do a low-impact query on the DB table before writing anything, and if it's empty, manually set the ID of the first record to 1000. I forget whether subsequent writes would follow the previous pkId (i think they might but i'm not sure), but even if not, you could always manually set each object's Id to be max( existing ID's )+1...
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Eduardo Fuentes
Appian Employee
over 11 years ago
The SequenceGenerator annotation is only compatible with the following RDBMS'
Oracle DB
IBM DB2
More information at
wiki.eclipse.org/.../PrimaryKey
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>