We're updating the issue view to help you get more done. 

Throw an exception when two entities are declared with the same name

Description

Two entities with the same name in different packages

1 2 3 4 5 6 7 . └── orders ├── current │   └── Purchase.java └── old └── Purchase.java

old

1 2 3 4 5 6 7 @Entity @Access(AccessType.FIELD) @Table(name="purchase_old ") public class Purchase { @Id public String id; }

current

1 2 3 4 5 6 7 @Entity @Access(AccessType.FIELD) @Table(name="purchase_current") public class Purchase { @Id public String uid; }

Test for show

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 @Test public void test() { EntityManager em = getOrCreateEntityManager(); em.getTransaction().begin(); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<org.hibernate.test.model.orders.current.Purchase> cq = cb .createQuery(org.hibernate.test.model.orders.current.Purchase.class); cq.from(org.hibernate.test.model.orders.current.Purchase.class); log.info("Must select from current"); em.createQuery(cq).getResultList(); CriteriaQuery<org.hibernate.test.model.orders.old.Purchase> cq1 = cb.createQuery(org.hibernate.test.model.orders.old.Purchase.class); cq1.from(org.hibernate.test.model.orders.old.Purchase.class); log.info("Must select from old"); em.createQuery(cq1).getResultList(); em.getTransaction().commit(); em.close(); }

when get result from current, i have generated select from old
i have log message
10:30:33,183 INFO ModelTwoPurchaseEntityTest:25 - Must select from current
10:30:33,210 INFO QueryTranslatorFactoryInitiator:47 - HHH000397: Using ASTQueryTranslatorFactory
10:30:33,245 DEBUG QueryTranslatorImpl:288 - parse() - HQL: select generatedAlias0 from org.hibernate.test.model.orders.old.Purchase as generatedAlias0

Environment

None

Status

Assignee

Vlad Mihalcea

Reporter

Станислав Губанов

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.3.7

Priority

Major