-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-4528 - Applied patch (with minor cleanup)
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17849 1b8cb986-b30d-0410-93ca-fae66ebed9b2
- Loading branch information
1 parent
f8fef6c
commit 2176af1
Showing
4 changed files
with
308 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
annotations/src/test/java/org/hibernate/test/annotations/idclass/DomainAdmin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// $Id$ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2005, JBoss Inc., and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.hibernate.test.annotations.idclass; | ||
|
||
import java.io.Serializable; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.IdClass; | ||
import javax.persistence.NamedNativeQuery; | ||
import javax.persistence.Table; | ||
|
||
|
||
/** | ||
* A DomainAdmin. | ||
* | ||
* @author <a href="mailto:stale.pedersen@jboss.org">Stale W. Pedersen</a> | ||
*/ | ||
@Entity | ||
@Table(name = "domainadmin") | ||
@IdClass(DomainAdminId.class) | ||
@NamedNativeQuery(name = "DomainAdmin.testQuery", | ||
query = "select * from domainadmin da where da.domain_name = 'org'", | ||
resultClass = org.hibernate.test.annotations.idclass.DomainAdmin.class) | ||
public class DomainAdmin implements Serializable { | ||
|
||
@Id | ||
@Column(name = "domain_name") | ||
private String domainName; | ||
|
||
@Id | ||
@Column(name = "admin_user") | ||
private String adminUser; | ||
|
||
@Column(name = "nick_name") | ||
private String nickName; | ||
|
||
public DomainAdmin() { | ||
} | ||
|
||
public String getDomainName() { | ||
return domainName; | ||
} | ||
|
||
public void setDomainName(String domainName) { | ||
this.domainName = domainName; | ||
} | ||
|
||
public String getAdminUser() { | ||
return adminUser; | ||
} | ||
|
||
public void setAdminUser(String adminUser) { | ||
this.adminUser = adminUser; | ||
} | ||
|
||
public String getNickName() { | ||
return nickName; | ||
} | ||
|
||
public void setNickName(String nickName) { | ||
this.nickName = nickName; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
annotations/src/test/java/org/hibernate/test/annotations/idclass/DomainAdminId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// $Id$ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2005, JBoss Inc., and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.hibernate.test.annotations.idclass; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* A DomainAdminId. | ||
* | ||
* @author <a href="mailto:stale.pedersen@jboss.org">Stale W. Pedersen</a> | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class DomainAdminId implements Serializable { | ||
|
||
private String domainName; | ||
|
||
private String adminUser; | ||
|
||
public DomainAdminId() { | ||
} | ||
|
||
public DomainAdminId(String domainName, String adminUser) { | ||
this.domainName = domainName; | ||
this.adminUser = adminUser; | ||
} | ||
|
||
public String getDomainName() { | ||
return domainName; | ||
} | ||
|
||
public void setDomainName(String domainName) { | ||
this.domainName = domainName; | ||
} | ||
|
||
public String getAdminUser() { | ||
return adminUser; | ||
} | ||
|
||
public void setAdminUser(String adminUser) { | ||
this.adminUser = adminUser; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
return ( ( o instanceof DomainAdminId ) && domainName.equals( ( ( DomainAdminId ) o ).getDomainName() ) && | ||
adminUser.equals( ( ( DomainAdminId ) o ).getAdminUser() ) ); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return ( domainName + adminUser ).hashCode(); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
annotations/src/test/java/org/hibernate/test/annotations/idclass/IdClassCompositePKTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// $Id$ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2005, JBoss Inc., and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.hibernate.test.annotations.idclass; | ||
|
||
import org.hibernate.Query; | ||
import org.hibernate.Session; | ||
import org.hibernate.Transaction; | ||
import org.hibernate.test.annotations.TestCase; | ||
|
||
/** | ||
* A IdClassTestCase. | ||
* | ||
* @author <a href="mailto:stale.pedersen@jboss.org">Stale W. Pedersen</a> | ||
* @version $Revision: 1.1 $ | ||
*/ | ||
public class IdClassCompositePKTest extends TestCase { | ||
|
||
public void testEntityMappningPropertiesAreNotIgnored() { | ||
Session s = openSession(); | ||
Transaction tx = s.beginTransaction(); | ||
DomainAdmin da = new DomainAdmin(); | ||
da.setAdminUser( "admin" ); | ||
da.setDomainName( "org" ); | ||
|
||
s.persist( da ); | ||
Query q = s.getNamedQuery( "DomainAdmin.testQuery" ); | ||
assertEquals( 1, q.list().size() ); | ||
|
||
tx.rollback(); | ||
s.close(); | ||
} | ||
|
||
protected Class[] getMappings() { | ||
return new Class[] { | ||
DomainAdmin.class | ||
}; | ||
} | ||
} |