[jboss-user] [EJB 3.0] - EJB3 - load Sql Query From Xml Deployment Descriptor

grdzeli_kaci do-not-reply at jboss.com
Sun Aug 13 10:23:45 EDT 2006


hi all,
i'm trying working with ejb3 using xml eployment Descriptor.
here is my small example:
Table in Oracle DB

  | CREATE TABLE "TEST"."PERSON" 
  |    (	"ID" NUMBER NOT NULL ENABLE, 
  | 	"NAME" VARCHAR2(255), 
  | 	"SURNAME" VARCHAR2(255), 
  | 	"AGE" NUMBER, 
  | 	 CONSTRAINT "PK_ID" PRIMARY KEY ("ID")
  |    )
  | 
EJB3 Entity Bean

  | import [...]
  | @Entity()
  | @Table(name="PERSON", schema="TEST")
  | public class PERSON implements Serializable {
  | 	//default serial version id, required for serializable classes.
  | 	private static final long serialVersionUID = 1L;
  | 	private Long id;
  | 	private Long age;
  | 	private String name;
  | 	private String surname;
  | 
  |     public Test() {
  |     }
  | 
  | 	@Id()
  | 	@SequenceGenerator(name = "idGenerator", sequenceName = "SEQ_ID")
  | 	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "idGenerator")
  | 	@Column(name="ID", unique=true, nullable=false, precision=22)
  | 	public Long getId() {
  | 		return this.id;
  | 	}
  | 	public void setId(Long id) {
  | 		this.id = id;
  | 	}
  | 
  | 	@Basic()
  | 	@Column(name="AGE", precision=22)
  | 	public Long getAge() {
  | 		return this.age;
  | 	}
  | 	public void setAge(Long age) {
  | 		this.age = age;
  | 	}
  | 
  | 	@Basic()
  | 	@Column(name="NAME", length=255)
  | 	public String getName() {
  | 		return this.name;
  | 	}
  | 	public void setName(String name) {
  | 		this.name = name;
  | 	}
  | 
  | 	@Basic()
  | 	@Column(name="SURNAME", length=255)
  | 	public String getSurname() {
  | 		return this.surname;
  | 	}
  | 	public void setSurname(String surname) {
  | 		this.surname = surname;
  | 	}
  | }
  | 
and my orm.xml file 


  | <?xml version="1.0" encoding="UTF-8"?>
  | <entity-mappings 
  | 	xmlns="http://java.sun.com/xml/ns/persistence" 
  | 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  | 	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" 
  |         version="1.0">	
  | 	<package>com.magti.businesslayer.ejb3entity.oracle</package>
  |         <named-native-query name="getPersons">select * from Test</named-native-query>
  | 	<entity class="PERSON">
  | 		<primary-key-join-column name="id"/>
  | 		<table name="PERSON">
  | 			<unique-constraint>
  | 				<column-name>id</column-name>
  | 				<column-name>age</column-name>
  | 				<column-name>name</column-name>
  | 				<column-name>surname</column-name>
  | 			</unique-constraint>
  | 		</table>
  | 	</entity>
  | </entity-mappings>
  | 

how i can load this sql query in my session fasade bean ?
i tryed this but it does not working :

Persons Session Fasade Bean

  | @Stateful
  | @TransactionManagement(TransactionManagementType.BEAN)
  | @Remote(Fasade.class)
  | public class PersonFasadeBean implements PersonFasade
  | {	
  | 	@PersistenceContext(unitName = "TEST")
  | 	private EntityManager oracleManager;
  | 	@Resource public UserTransaction utx;
  | 	public Test[] getTests() throws IllegalStateException, SecurityException, SystemException {
  | 		List _list = oracleManager.createNativeQuery("getTests").getResultList();
  | 		System.out.println(_list.size());
  | 		return null;
  | 	}
  | }
  | 

and i got an errot like this :

  | 04:17:19,984 WARN  [JDBCExceptionReporter] SQL Error: 900, SQLState: 42000
  | 04:17:19,984 ERROR [JDBCExceptionReporter] ORA-00900: invalid SQL statement
  | 

can anybody help me :(
is there eny docs about this ?
thanks.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3964839#3964839

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3964839



More information about the jboss-user mailing list