-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: JPA TableGenerator problem: SQL contains table name thrice?!
PostPosted: Mon May 17, 2010 3:44 pm 
Beginner
Beginner

Joined: Thu Dec 29, 2005 12:08 pm
Posts: 31
Location: Acton, MA
A TableGenerator and referencing @GeneratedValue incantation like this:
Code:
@Entity(name = "PostalAddress")
@Table(name = "PostalAddress")
@TableGenerator(
  name = "PostalAddressEntityIDGenerator",
  table = "JPAGenerators",
  pkColumnName = "generatorName",
  pkColumnValue = "PostalAddressEntityIDGenerator",
  valueColumnName = "generatorValue",
  allocationSize = 1
)
public class PostalAddressEntity {
  @Column(name = "id")
  @GeneratedValue(strategy = GenerationType.TABLE, generator = "PostalAddressEntityIDGenerator")
  @Id
  private long id;

  /* etc. */
}


...produces SQL like this (for getting the next ID):

Code:
select generatorValue from JPAGenerators.JPAGenerators.JPAGenerators where generatorName = 'PostalAddressEntityIDGenerator' for update


Why is this being repeated three times?

This is Hibernate 3.5.2-Final.

Best,
Laird


Last edited by ljnelson on Mon May 17, 2010 4:58 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: JPA TableGenerator problem: SQL contains table name thrice?!
PostPosted: Mon May 17, 2010 4:33 pm 
Beginner
Beginner

Joined: Thu Dec 29, 2005 12:08 pm
Posts: 31
Location: Acton, MA
Should have mentioned: I'm using H2 for a database, and the H2Dialect.


Top
 Profile  
 
 Post subject: Re: JPA TableGenerator problem: SQL contains table name thrice?!
PostPosted: Mon May 17, 2010 4:45 pm 
Beginner
Beginner

Joined: Thu Dec 29, 2005 12:08 pm
Posts: 31
Location: Acton, MA
I see from http://viewvc.jboss.org/cgi-bin/viewvc. ... iew=markup that a rather...um...liberal approach is taken towards inferring catalog and schema bits.

Specifically, in my example, which deliberately does not qualify the name with a default schema (since that's specified in the JPA-described orm.xml file, which is where, as I understand it, you're allowed to put things like the schema name to use if one is not otherwise specified), "JPAGenerators" is taken--mistakenly--to be the catalog, schema and table name. I don't know why it was thought that this was a valid assumption to make.

I will file a JPA specification violation bug.

Thanks,
Laird


Top
 Profile  
 
 Post subject: Re: JPA TableGenerator problem: SQL contains table name thrice?!
PostPosted: Mon May 17, 2010 5:17 pm 
Beginner
Beginner

Joined: Thu Dec 29, 2005 12:08 pm
Posts: 31
Location: Acton, MA
Bug filed: http://opensource.atlassian.com/project ... e/HHH-5235


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.