Setstring method of Hibernate query interface: bind parameters with mapping type of string
                                        
                    •
                    Java                                    
                Grammar 1
setString(int position,String val)
Example
String hql = "from UserForm where sex=?"; //定义查询HQL语句 Query query = session.createQuery(hql); //执行查询语句,获取Query对象 query.setString(0,"女"); //设置HQL语句参数
Grammar 2
setString(String name,String val)
Example
String hql = "from UserForm where sex=:sex";  //定义查询HQL语句
Query query = session.createQuery(hql);  //执行查询语句获取Query对象
query.setString("sex","女");  //设置HQL语句参数
                
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        