sawan parihar

Ranch Hand
+ Follow
since Aug 24, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sawan parihar

I found the sol. Just in case someone might encounter this here is the sol:

Not sure this is the right way but it works.

For SQLServer the query should have been like:

select * from schema..image

Now i specified the default schema name in hibernate.properties file:
hibernate.default_schema=schema.

The schema name is 'schema' but note that '.' after the schema name. Without the '.' hibernate query will be select * from schema.name. Just one '.' this won't work. I need two '.' and I specified one in the properties file.

This is how it works.

Thanks.
[ August 01, 2007: Message edited by: sawan parihar ]
Thanks.

The table does exist.
It just came to my mind that the problem is the schema name .
I am using BasicDataSource to connect and not sure how can I specify the schema name.


<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName>
<value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value></property>
<property name="url">
<value>jdbc:sqlserver://testdev01:1433</value></property>
<property name="username"><value>admin</value></property>
<property name="password"><value>password</value></property>



the query should have been something like this:

select * from schema..Image as Image.


Any idea how can I specify the schema name?

Thanks.
[ July 31, 2007: Message edited by: sawan parihar ]
Hi,

Env: Spring,Hibernate, SQLServer

I am trying to fetch the records from "Image" table. My query is pretty simple:
public List getAll() {
return getHibernateTemplate().find("from Image");
}

But the query that hibernate generates is:

select image0_.UID as UID0_ from Image image0_

Exception trace:
SEVERE: Invalid object name 'Image'.
Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2223)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:849)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:832)
at sawa.parihar.database.HibernateTestDAO.getAll(HibernateTestDAO.java:10)
at sawa.parihar.database.HibernateSpringTest.test(HibernateSpringTest.java:21)
at sawa.parihar.database.HibernateSpringTest.main(HibernateSpringTest.java:41)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'Image'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.getPrepExecResponse(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PreparedStatementExecutionRequest.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.CancelableRequest.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeRequest(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:205)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
... 14 more


Any help is highly appreciated.

Thanks,
Sawan
Hi,
you always call method on the stub and not on the remote object.

That means , rule of thumb is that Bean cant access any of its client,isinit?



Depends upo the question. If it is written that the client is a java client that the question will be more confusing. But in the above case its not written that client is a java client.

Why B is correct?



Because R is remote and B has local interfaces.

hope it helps.
R is the client and that is why B cannot invoke methods on the client. The question is not very clear but it depends how you interpret it. The client can be anything.. no java .. right ... that means B can't invoke the methods.


Hope it helps.
Hello,
The question says choose two option that means a and d are correct. Also if it is about stateful session bean then a,d,f are correct. But it't not written that its for stateful session bean.

Cheers.

I don't see why this code would throw an exception, please enlighten me...



The exception will be thrown because we are trying to commit a transaction that is alreday marked for rollback. It will be helpful if for example we consider weblogic. It throws AppSetRollbackOnlyException to indicate that a transaction was marked for rollback by an application component.

http://e-docs.bea.com/wls/docs81/javadocs/weblogic/transaction/AppSetRollbackOnlyException.html

Hope it helps.
Hello bhila,


g)Upon execution of this code, the container ensures that the transaction is not committed



If the transaction is already marked for rollback then container will make sure that it will never commit. This makes the option g correct.


d This code will throw an exception at runtime.


This is also correct. Most of the container will throw error in this case. But then it again depends upon the container implementation. In case of weblogic "AppSetRollbackOnlyException" will be thrown. I am not very sure that what specs say about this but I believe that its upto the container provider.

Hope it helps.
If you are familiar with EJB technologies then you can go for SCBCD. Also would like to add that for SCBCD (H&F+ Specs) is enough to score above 90%.

Best of Luck.
[ August 12, 2005: Message edited by: sawan parihar ]
Hello,
The environment entries can be set by bean provider,app assembler or the deployer. I believe that 3 is right.

is it required that the class shoudl have instane variables as public or is it suffciet it has public accessor methods for the instances.



Yes the class should have public fields.

my question is what if it goes through ejbActivatre?
in that case, ejbCreate, ejbPostCreate will not be called



Yes ejbCreate, ejbPostCreate will not be called in the above case.

ejbCreate, ejbPostCreate will be called when you are creating the entity bean whereas ejbActivate() is called to activate the entity bean that is already created.

so does ejbActivate should set the cmp, cmr fields



No. As the bean is already created there is no need to set the values.
SCBCD 1.3 requires ejb 2.0