Ivy chen

Greenhorn
+ Follow
since Aug 31, 2010
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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ivy chen

Hi:

i have a String variable and its length is larger than 60000.
i want to insert this string variable into a column call "result" (dataType is text,DataBase:Sybase,Table call "Log")

in the Log.hbm.xml,i set the "result's type" is org.springframework.orm.hibernate3.support.ClobStringType

here is the Log.hbm.xml:


here is the Log.class:


here is the Spring's application.xml


hibernate do insert this String variable "result" into the DateBase,but it is not intact,the variable's length is only 2^16(16384).

how can i insert this String variable completely?

thanks!

Lucas Mireles wrote:You say you are implementing SessionAware but you did not implement setSession.

You should have:



hello Lucas:In fact,in my code, i do have implemented setSession.I just omit the setter and getter in this topic.

the problem still goes on.
12 years ago
i think you can use the "DetachedCriteria" to fit your demand.
Hello,everyone: thanks for reading this topic,and here is my question.

Question :When i getting value from the jsp,however a nullPointException comes out?below is my code,how does this problem come across?

Here is the steps:
(1).in my project, if one user login successfully (in the 'Login.jsp',i put this user into a session) ,then he can update his profile in the "userUpdate.jsp".
(2).After that, the "UserAction" will deal with it with the new data.

Unfortunately,the "UserAction" can not get the 'session' even and the value from the jsp ,and a NullPointException come out

Note: i try to creat a new action class:"UserUpdateAction" and take the place of the method "UserUpdate" of the "UserAction", the Update become Ok

waiting for your help,thanks and best regards

Below are my codes:

1 . UserAction(a struts2 action):NullPointException come across at line '53' and '54',that is to say:nothing can get from the jsp



2. Here is my "userUpdate.jsp":







12 years ago
In an action, there will be lots of methods,"struts2 docs" tells me i can override validateXxx() to validate the specific method in the action.

And also we can use "actionClass-validation.xml" or Vlidation Annotation to validate methods in the action.

question:Can I use these "actionClass-validation.xml" or "Vlidation Annotation" to validate the specific method in the action?

------------------------------------------------

For example:
in the "myStrutsAction",i have 2 methods:"barRegist()" and "fooLogin()", Three parameters:"name","password","age";

in method"barRegist()",i will use these three parameters to regist an User,that i should validate the whole parameters.

in method"fooLogin()",i just only use "name" and "password" for User login, i just have to validate "name" and "password".

----------------------------------------------

Then how can i config the "actionClass-validation.xml" or "Vlidation Annotation" to validate the specific method?

i know "Client Validation" can do this,it just like a basic validation, it can not satisfy my requirement and it can not set a "message".

waiting for your answer~Thanks!
12 years ago

Mark Spritzler wrote:While I am not sure if LocalSessionFactoryBean has a property called eventListeners.

It looks to me like you have a circular reference going on here and Spring can't figure out which comes first, the Chicken or the Egg.

SessionFactory --- EventListeners -- EventListener -- EventListernerDAO -- SessionFactory

See how the references/dependencies work its way back to the SessionFactory.

Mark



As you say,when i config the "Hibernate EventListener" in the Spring,i found there was a circular between the sessionFactory and the Listeners(obviously this configaration is unreasonable and make me confused).

Dear Mark:
Is there any way that i can config the "Hibernate EventListener" in the Spring?
1/use an MethodInterceptor in a aspect??
2/config the "Hibernate EventListener" in the "hibernate.cfg.xml"??
3/or any other better ways???

Waiting for your guidance.....thanks~
13 years ago
If i just use Hibernate ( without Spring ) , i can define these listeners in the hibernate.cfg.xml, and every thing goes well.

i need your help~

IVY~
13 years ago
In my practise,i want to persist some information about Hibernate Event into the dataBase by Spring.

And i configed the Hibernate Event Listener (Such as:PostInsertEventListener) in the ApplicationContext.

How ever problems occur.

Here are the Exceptions out print in MyEclipse:





Here are my beans and ApplicationContext.xml

HibernateEventListener( which is a table to save the information )


PostInsertEvent(get the information of the Insert Action )


HibernateEventListenerDaoImpl (save the event information into the dataBase)


ApplicationContext.xml,I thing the problems occur in the tag:<property name="eventListeners">( in line 30)




hunger for your answer,Thanks~







13 years ago

Mark Spritzler wrote:Well, I found a few problems.

1) User and Order should not be a Spring Bean, they are domain objects and hold state. Not good for a Spring Bean
2) You are creating an ApplicationContext object directly in your OrderService, it should be outside of your classes that you are defining as Beans. So one problem is everytime you call addOrder, it goes and creates a brand new ApplicationContext. You should only have one of these for your entire application. ApplicationContext is a heavy-weight object that can take a little bit of time to instantiate, There is a whole bunch of steps in Initialization that occurs when creating an ApplicationContext.

3) This is not a Spring bug, but a Hibernate issue. You have from User to Order a cascade option, but you do not have a cascade option from Order to User. And since you save the Order, it will not do anything to User. And I would assume this is a new user and the database would have a FK constraint in Order table for the user id. So the User information must be in the User table before any Order can be inserted into the Order table for that User. But you are looking up a User, so if it exists in the database, then that wouldn't be a problem.

Please post your exception stack trace because we are missing that context information on what is you actual problem.

Mark



Dear Mark:
Thanks for your answer,with your help,i solve the problem.And you help me to know more about the Spring.

Next time i will post the exception in the topic.
13 years ago
hi,everyone~

I'm new to spring~now I'm doing a “one to many”practice with spring & hibernate~how ever somes problems come out~

Details:
in the database(Mysql) there are two tables:"User" & "Order"~(One to Many): one "User" to many "Order"~i want to insert data into the table"Order"~

Problems:can not insert the data into the table"Order".and the problems cause in the code "OrderServiceImpl".

here is my code:
(Spring:ApplicationContext.xml)


User.hbm.xml


Order.hbm.xml


OrderDaoImpl


OrderServiceImpl(problems cause in these code)


i don't know how to solve the problems~help~thanks~

another question:when i add the spring capability into the project, the speed of querying is lower than only add hibernate into the project~why would it happen?

13 years ago
Hi all~

i'm new to Hibernate.Now i'm falling into the "update" problem of hibernate~

i user the HQL editor in Myeclipse to test the HQL update statement "update Order as o set o.orderName = 'rfv' where o.orderName = 'bec'"

error comes:"org.hibernate.hql.QueryExecutionRequestException: Not supported for DML operations "

when i run the class"testF" no errors come out

let me know why this erroe comes out

thanks~~~

-----------------------------------------------------------------------------------------

here is my DB table
1/ Table "user "


2/Table "Order"


------------------------------------------------------

Java Class
1/Class "User"


2/Class "Order"

---------------------------------------------
***.hbm.xml
1/User.hbm.xml


2/Order.hbm.xml

------------------------------------------------------
Class "OrderDaoImpl"

-----------------------------------------------------
The test class "TestF"

Sean Clark wrote:Hey,

I think you just want to save the username in the session, I'm not sure you can use <jsp: setAttribut> to pass the username to servlet(B).
The only other option I can see would be to send the username as part of JSP(B)'s form as a hidden input and read it again in servlet(B), though I personally wouldn't do this as this value could be tampered with by the client.

Your choice though.

Sean



thank you Sean Clark!

Would you please show me the right way?

UpdateDB.jsp(choose which user should be updated)



UpData_userInfor.jsp (that's the JSP(B))


doUpdate_userInfor_servlet (that's the sevlet(B))


thanks a lot~
13 years ago
JSP

Bear Bibeault wrote:Again, I'm confused. A JSP is the end target of a request. Anything done in the JSP should be for the sole purpose of rendering the display. So saying things like "passing the value of <c:set> to a filter" doesn't make a whole lot of sense. What is it that you are really trying to do?



thank u~
I'm doing the exercise of update the sql.

at the begining, I though I can set a property in a JavaBean by the <c: set>,then I can use a sevlet or a filter to get this property.

I'm wrong.

I still have a question:In my project ,a user can update his individual Information in jsp(A), first user fill in his userName (e.g ABC) , servlet(A) get this userName and check wether this userName is in the dateBase , if yes,dispatcher to JSP(B) to let user input his information(PS: userName will be displayed in JSP(B) ),after he finish filling in his information,parameters wil be sent as a part of form to servlet(B).In servlet (B) userName(ABC) is still needed as a parameter to update dateBase.

How can i get the userName in servlet(B)? should I set userName as an attribute in session at the begining or I should user the taglib<jsp: setAttribut> to set the userName in JSP(B) , then sent it to the servlet(B)?

thank you very much!
13 years ago
JSP

Bear Bibeault wrote:Your question makes no sense as stated. What is the relationship between the JSP and the servlet? Why are you just using normal request parameters? Why would a servlet need info from the JSP that isn't submitted as part of a form?



got it~thanks~I'm new to JSTL.

I feel quite confuse about the function of<c:set target>.it set the property of a javabean.

Can I get the value from the Bean?

if(yes){
how to ? that I can pass the value as a parameter to a filter or to some other codes?
}
if(no){
Is it the only way that I just can use the <c: out> to get or output the value of the property in other JSPs when I had set the "scope" in the taglib"<jsp:useBean>"?
}
13 years ago
JSP