My Account entity Primary key is generated using GenerationType.Table stratergy.
@Entity
@Table(name="ACCOUNT")
public class Account {
@Id
@GeneratedValue(strategy=GenerationType.TABLE , generator="tablegenerator")
@TableGenerator(name="tablegenerator", table="ifinances_keys", pkColumnName="PK_NAME",valueColumnName="PK_VALUE")
@Column(name="ACCOUNT_ID")
private Long accountId;
I have defined a table ifinances_key to store this generated key and after persisting data , the following key is generated :-
Ifinances_Key Table
PK_NAME, PK_VALUE
ACCOUNT 8
My Account Table has the following data :
ACCOUNT_ID | Rest of the columns ---->
200
300
350
When I run the following query
SELECT * FROM account a natural join ifinances_keys b ;
I am getting all the data ie :
ACCOUNT_ID | Rest of the columns ---->
200
300
350
Please explain the internal working of this strategy and how this Join is working?
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
SELECT
*
FROM
account a NATURAL
JOIN
ifinances_keys b