Beginner |
|
Joined: Mon Mar 07, 2005 9:15 am Posts: 26
|
Hi,
I would like to use Hibernate3's class <where> tag and the
various sql-insert/sql-delete/sql-update tags to filter and control access to
the DB. I would like to use the tabl'es columns to control this.
For example: For the class Child I should only view objects with
values for g1=X and g2=Y. Values for X and Y are only known at
the session's start. How can I pass these to Hibernate when I
perform a creatSQL for example? What about when I load or
update an object?
TIA,
Hugo Ferreira.
Hibernate version:
Hibernate 3 (CVS)
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="pt">
<class
name="Child"
table="browser.actor"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
where="g1<=2 AND g2<=2"
>
<meta attribute="class-description">
Class generated via hbm2java.
Meta generated session aware
constructor is included.
@author hbm2java
</meta>
<meta attribute="extra-import">uy.Session</meta>
<meta attribute="class-code">
<![CDATA[
private String user;
private int access_per_group;
public Child(Session s) {
user = s.getUser();
int[] access = (int[])s.getAccessRights("browser.actor");
setG1( new Integer( access[0] ) );
setG2( new Integer( access[1] ) );
//setG3( new Integer( access[2] ) );
//setG4( new Integer( access[3] ) );
//setG5( new Integer( access[4] ) );
//setG6( new Integer( access[5] ) );
//setG7( new Integer( access[6] ) );
}
]]>
</meta>
<id
name="id"
column="idactor"
type="long"
>
<generator class="sequence">
<param name="sequence">idactor_seq</param>
</generator>
</id>
<property
name="name"
type="string"
update="true"
insert="true"
access="property"
column="nameac"
/>
<property
name="email"
type="string"
update="true"
insert="true"
access="property"
column="email"
/>
<property
name="address"
type="string"
update="true"
insert="true"
access="property"
column="address"
/>
<!-- not-null="true" -->
<many-to-one
name="accommodationType"
class="Parent"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
access="property"
column="typela"
/>
<property
name="g1"
type="integer"
update="true"
insert="true"
access="property"
column="g1"
/>
<property
name="g2"
type="integer"
update="true"
insert="true"
access="property"
column="g2"
/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
None
Full stack trace of any exception that occurs:
None
Name and version of the database you are using:
PostgreSQL 7.4
The generated SQL (show_sql=true):
none
Debug level Hibernate log excerpt:
none
|
|