| 1 | <!DOCTYPE hibernate-mapping PUBLIC |
|---|
| 2 | "-//Hibernate/Hibernate Mapping DTD 3.0//EN" |
|---|
| 3 | "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> |
|---|
| 4 | |
|---|
| 5 | <hibernate-mapping package="edu.rpi.metpetdb.client.model"> |
|---|
| 6 | <class name="Project" table="projects"> |
|---|
| 7 | <id name="id" column="project_id" unsaved-value="0"> |
|---|
| 8 | <generator class="sequence"> |
|---|
| 9 | <param name="sequence">project_seq</param> |
|---|
| 10 | </generator> |
|---|
| 11 | </id> |
|---|
| 12 | <version name="version" /> |
|---|
| 13 | <property name="name" column="name" /> |
|---|
| 14 | <property name="description" column="description" /> |
|---|
| 15 | |
|---|
| 16 | <many-to-one name="owner" column="user_id" lazy="false" /> |
|---|
| 17 | |
|---|
| 18 | <set name="members" table="project_members"> |
|---|
| 19 | <key column="project_id" /> |
|---|
| 20 | <many-to-many class="User" column="user_id" /> |
|---|
| 21 | </set> |
|---|
| 22 | |
|---|
| 23 | <set name="invites" table="project_invites"> |
|---|
| 24 | <key column="project_id" /> |
|---|
| 25 | <many-to-many class="User" column="user_id" /> |
|---|
| 26 | </set> |
|---|
| 27 | |
|---|
| 28 | <set name="samples" table="project_samples"> |
|---|
| 29 | <key column="project_id" /> |
|---|
| 30 | <many-to-many class="Sample" column="sample_id" /> |
|---|
| 31 | </set> |
|---|
| 32 | </class> |
|---|
| 33 | |
|---|
| 34 | <query name="Project.byId"> |
|---|
| 35 | from Project p |
|---|
| 36 | inner join fetch p.owner |
|---|
| 37 | where p.id = :id |
|---|
| 38 | </query>
|
|---|
| 39 |
|
|---|
| 40 | <query name="Project.byOwnerId">
|
|---|
| 41 | from Project p
|
|---|
| 42 | inner join fetch p.owner
|
|---|
| 43 | where p.owner.id = :ownerId
|
|---|
| 44 | </query>
|
|---|
| 45 |
|
|---|
| 46 | <query name="Project.byOwnerId,size">
|
|---|
| 47 | select count(*) from Project p
|
|---|
| 48 | inner join p.owner
|
|---|
| 49 | where p.owner.id = :ownerId
|
|---|
| 50 | </query>
|
|---|
| 51 |
|
|---|
| 52 | <query name="Project.byOwnerId/name">
|
|---|
| 53 | from Project p
|
|---|
| 54 | inner join fetch p.owner
|
|---|
| 55 | where p.owner.id = :ownerId
|
|---|
| 56 | order by p.name
|
|---|
| 57 | </query>
|
|---|
| 58 |
|
|---|
| 59 | <query name="Project.byOwnerId/owner">
|
|---|
| 60 | from Project p
|
|---|
| 61 | inner join fetch p.owner
|
|---|
| 62 | where p.owner.id = :ownerId
|
|---|
| 63 | order by p.owner.emailAddress
|
|---|
| 64 | </query> |
|---|
| 65 | |
|---|
| 66 | <query name="Project.samples,size"> |
|---|
| 67 | select count(*) from Project p |
|---|
| 68 | inner join p.samples |
|---|
| 69 | where p.id = :id |
|---|
| 70 | </query> |
|---|
| 71 | <query name="Project.samples/sesarNumber"> |
|---|
| 72 | from Project p |
|---|
| 73 | inner join p.samples as sample with sample.id = :id |
|---|
| 74 | order by sample.sesarNumber |
|---|
| 75 | </query> |
|---|
| 76 | <query name="Project.samples/alias"> |
|---|
| 77 | from Project p |
|---|
| 78 | inner join p.samples |
|---|
| 79 | where p.id = :id |
|---|
| 80 | </query> |
|---|
| 81 | <query name="Project.samples/owner"> |
|---|
| 82 | from Project p |
|---|
| 83 | inner join p.samples as sample with sample.id = :id |
|---|
| 84 | order by sample.owner |
|---|
| 85 | </query> |
|---|
| 86 | <query name="Project.samples/rockType"> |
|---|
| 87 | from Project p |
|---|
| 88 | inner join p.samples as sample with sample.id = :id |
|---|
| 89 | order by sample.rockType |
|---|
| 90 | </query> |
|---|
| 91 | <query name="Project.samples/collectionDate"> |
|---|
| 92 | from Project p |
|---|
| 93 | inner join p.samples as sample with sample.id = :id |
|---|
| 94 | order by sample.collectionDate |
|---|
| 95 | </query> |
|---|
| 96 | <query name="Project.samples/publicData"> |
|---|
| 97 | from Project p |
|---|
| 98 | inner join p.samples as sample with sample.id = :id |
|---|
| 99 | order by sample.publicData |
|---|
| 100 | </query> |
|---|
| 101 | <query name="Project.samples/latitude"> |
|---|
| 102 | from Project p |
|---|
| 103 | inner join p.samples as sample with sample.id = :id |
|---|
| 104 | order by sample.location |
|---|
| 105 | </query> |
|---|
| 106 | <query name="Project.samples/longitude"> |
|---|
| 107 | from Project p |
|---|
| 108 | inner join p.samples as sample with sample.id = :id |
|---|
| 109 | order by sample.location |
|---|
| 110 | </query> |
|---|
| 111 | <query name="Project.samples/country"> |
|---|
| 112 | from Project p |
|---|
| 113 | inner join p.samples as sample with sample.id = :id |
|---|
| 114 | order by sample.country |
|---|
| 115 | </query> |
|---|
| 116 | <query name="Project.samples/description"> |
|---|
| 117 | from Project p |
|---|
| 118 | inner join p.samples as sample with sample.id = :id |
|---|
| 119 | order by sample.description |
|---|
| 120 | </query> |
|---|
| 121 | <query name="Project.samples/collector"> |
|---|
| 122 | from Project p |
|---|
| 123 | inner join p.samples as sample with sample.id = :id |
|---|
| 124 | order by sample.collector |
|---|
| 125 | </query> |
|---|
| 126 | <query name="Project.samples/locationText"> |
|---|
| 127 | from Project p |
|---|
| 128 | inner join p.samples as sample with sample.id = :id |
|---|
| 129 | order by sample.locationText |
|---|
| 130 | </query> |
|---|
| 131 | </hibernate-mapping> |
|---|