History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEADEV-17184
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Peter Gromov
Reporter: Taras Tielkes
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
IDEA: Development

Renaming Java class from Hibernate mapping inserts JPA annotation

Created: 16 May 07 21:01   Updated: 26 Jul 07 12:11
Component/s: J2EE.Hibernate
Fix Version/s: Selena 7096

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 6,951
Fixed in build: 7,095


 Description  « Hide
<class name="test.baz.bar.Foo" table="foo">
  <id name="id" column="fid">
    <generator class="assigned"/>
  </id>
  <property name="barId" type="integer"/>
</class>

1) Caret is on "Foo", inside attribute "name" of element <class>. Refactor->Rename is invoked.
2) IDEA asks

Class 'Foo' belongs to Persistent Object Model Helper 'Foo'
Do you want to rename Persistent Object Model Helper 'Foo' instead?
[Yes] [No]

We choose "No", we want to rename the real Java class. Next, we choose "Wolf" as the new class name.
3) Class is properly renamed, however, a class-level annotation is added:

@javax.persistence.Entity(name = "Foo")
public class Wolf {
    // ...
}

Some thoughts:

  • obviously usage of "javax.persistence.Entity" annotation is wrong, since I'm just using plain Hibernate3 (I don't even have this annotation class in my classpath)
  • the "correct variation" of current behavior would be to add an "entity-name" attribute to the <class> element inside the .hbm.xml file.

However, the majority of Hibernate projects does not use explicit entity names.
In such situations, the user wants to rename the Java class, and expects usages in HQL etc to automatically be included.

For a more detailed proposal to simplify this, see IDEA-12790.



 All   Comments   Work Log   Change History      Sort Order:
Alexander Chernikov - 01 Jun 07 15:34
Still occurs in 6990.

Alexander Chernikov - 01 Jun 07 17:38
The same happens if the mapping is not in hbm.xml, but in orm.xml.