I use it:
NetBeans IDE 6.7.1, Glassfish v2.1, Oracle 10 GE XE, Java 6 SE, Java 5EE,
From within a Statace EJB, I continue to have client types of organizations, I have an annotation: @Suvenes Generator (name = "CEC",) Sequence name = "custom_ad_sec") In the class, the primary key is automatically activated in the database from the sequence cust_id_seq, but I would rather have my maintains the customer first primary key 9900 9951, 9952 is the primary key of another customer. Output I of Glassfish v2.1
My ID is: 0
TopLink, Version: Oracle Top Link Required - 2.1 (Build BSFI-FCS) (10/19/2009))
Server: unknown file: / c: / document% 20 and% 20 settings / IOANNIS_PAPAIOANNOU / My% 20 document / netbusiness project / video club / dist / gfdeploy / videoclub-ejb_jar / -vc_pu login successful < / P>
My ID is: 9951
My ID is: 0
My ID (name = "customer") @ seewennes generator (name = "CEC", sequence Name = "cust_id_sec") universal Generic Category Customer Device Serializable {@Id @GeneratedValue (99)
@Entity @Table Strategy = generationType.sequence, generator = "seq") @ column (name = "CUST_ID") Id id; @column (name = "phone_number") private int phone number; @column (name = "first_name") private string first name; @column (name = "last_name") personal string lastName; @column (name = "credit") private int credit; @OneToMany private collection & lt; CustRentMovie & gt; Rent = New Arrestist & lt; Custanthanthovy & gt; (); Public int getCredit () {return credit; } Public Zero Set Credit (int credit) {this.credit = credit; } Public string getFirstName () {return firstName; } Public Zero SetFirst-name (string first name) {this.firstName = firstName; } Public int getId () {return ID; } Public Zero setId (int id) {this.id = id; } Public string getLastName () {lastName; } Public Zero setLlastName (string last name) {this.lastName = lastName; } Public int receipt number () {return phone number; } Public Zero setphone number (if phone number) {this.phoneNumber = phoneNumber; } Public Collection & lt; CustRentMovie & gt; GetRents () {Return Rent; } Public zero set (Collection & lt; CustRentMovie & gt; Rent) {this.rents = rents; }} Code of EJB:
@ Staltus Public Class Clark applies the Sensenbene Clerk Schnerremot {@ Peristons Contex (unit -name = "vc_pu" ) Private Entity Manager; Public Int Written Customers (Approximately Client Clients) {Client Customer = New Customer}; System.out.println ("My ID is:" + customer.getId ()); Customer.setFirstName (almostCustomer.getFirstName ()); Customer.setLastName (almostCustomer.getLastName ()); Customer.setphoneNumber (almostCustomer.getPhoneNumber ()); Em.persist (customer); System.out.println ("My ID is:" + customer.getId ()); Return customer .getId (); }} Database creates part of the script:
Create a table customer (cust_id number (5), phone number NUMBER (10) No, first Name is not VARCHAR2 (12), last_name VARCHAR2 (30) No, tap, - no credit card number (5, 2) DEFAULT 0 for any other person, custom custom_pac primary key (cust_id), - contract phone exchange ( Phone_Number)) / drop SEQUENCE cust_id_seq / SEQUENCE cust_id_seq Make MINVALUE 10000 MAXVALUE 99999 INRITMENT starting with 1 10000 Naucatch Nokal order Not /
Yiannis p.
I think you should change CREATE SEQUENCE cust_id_seq ... < Strong> 1 to ... INCREMENT BY 50 . Here's why.
The declared sequence increment must match the @suvenes generator 's allocation size is not specified and therefore the default for 50 is. But the true INCREMENT BY is not just 1, 50. Therefore there is a mismatch between allocation size and the actual INCREMENT BY .
Here's why it can cause a mismatch problem. TopLink Essentials (TLE) call NEXTVAL () at cust_id_seq . The sequence returns 10000 + 1 returns. TLE assumes that the sequence increases by 50 instead of 1 (the actual amount) (default JPA allocation size ). By getting TLE allocation size = 5001 to 9901
By the way, if you have the freedom to do this, consider upgrading TLE's successor (and). / P>
Comments
Post a Comment