package org.com.dao.impl;
import javax.annotation.Resource;
import java.util.Iterator;
import java.util.List;
import org.com.dao.PersonDAO;
import org.com.model.User;
import org.com.model.Person;
import org.hibernate.Hibernate;
import org.hibernate.SessionFactory;
import org.hibernate.Query;
import org.hibernate.type.Type;
import org.springframework.stereotype.Repository;
@ Resource
public class PersonDAOImpl implements PersonDAO
{
private SessionFactory sessionFactory;
public boolean login (User user)
{
String hql = "from User where username =? and password =? and role =?";
String [] params = new String [] {user.getUsername (), user.getPassword (), user.getRole ()};
@ SuppressWarnings ("deprecation")
Type [] types = new Type [] {Hibernate.STRING, Hibernate.STRING, Hibernate.STRING };
Query query = sessionFactory.getCurrentSession (). createQuery (hql);
query.setParameters (params, types);
Iterator iter = query.iterate ();
if (iter.hasNext ())
{
return true;
}
return false;
}
public void add (Person person)
{
sessionFactory.getCurrentSession (). save (person);
}
public void update (Person person)
{
Person old = (Person) sessionFactory.getCurrentSession (). get (Person.class, person.getPersonid ());
old.setName (person.getName ());
}
public void delete (int personid)
{
Person per = (Person) sessionFactory.getCurrentSession (). get (Person.class, personid);
sessionFactory.getCurrentSession (). delete (per);
}
@ SuppressWarnings ("unchecked")
public List
{
return sessionFactory.getCurrentSession (). createQuery ("from Person"). list ();
}
}
red line of code that have problems
I use Eclipse + Struts2 + Hibernate4.0 + Spring3.0
type of error is not resolved
I do not know how to change
Find Great God ! ! !
------ Solution ---------------------------------------- ----
access points slightly
------ Solution ------------------------------ --------------
points to the point of chanting ~ ~
------ For reference only --------------- ------------------------
------ For reference only ---------------------------------- -----
themselves
my grass
of how to do ah
to the sauce ?
velocity dispersion divided ! ! ! ! ! ! ! ! !
------ For reference only -------------------------------------- -
------ For reference only ---------------------------------- -----
how to solve ah
------ For reference only -------------------------- -------------
hibernate version is too high , you should 3.6.5.Final version below . Because Hibernate4.0 and above in , Hibernate.STRING outdated, no longer used
------ For reference only ----------------- ----------------------
landlord how to solve ? ? ? Find enlighten
------ For reference only ------------------------------------ ---
public static final NullableType LONG = new LongType ();
public static final NullableType SHORT = new ShortType ();
public static final NullableType INTEGER = new IntegerType ();
public static final NullableType BYTE = new ByteType ();
public static final NullableType FLOAT = new FloatType ();
public static final NullableType DOUBLE = new DoubleType ();
public static final NullableType CHARACTER = new CharacterType ();
public static final NullableType STRING = new StringType ();
public static final NullableType TIME = new TimeType ();
public static final NullableType DATE = new DateType ();
public static final NullableType TIMESTAMP = new TimestampType ();
public static final NullableType BOOLEAN = new BooleanType ();
public static final NullableType TRUE_FALSE = new TrueFalseType ();
public static final NullableType YES_NO = new YesNoType ();
public static final NullableType BIG_DECIMAL = new BigDecimalType ();
public static final NullableType BIG_INTEGER = new BigIntegerType ();
public static final NullableType BINARY = new BinaryType ();
public static final NullableType WRAPPER_BINARY = new WrapperBinaryType ();
public static final NullableType CHAR_ARRAY = new CharArrayType ();
public static final NullableType CHARACTER_ARRAY = new CharacterArrayType ();
public static final NullableType TEXT = new TextType ();
public static final Type BLOB = new BlobType ();
public static final Type CLOB = new ClobType ();
public static final NullableType CALENDAR = new CalendarType ();
public static final NullableType CALENDAR_DATE = new CalendarDateType ();
public static final NullableType LOCALE = new LocaleType ();
public static final NullableType CURRENCY = new CurrencyType ();
public static final NullableType TIMEZONE = new TimeZoneType ();
public static final NullableType CLASS = new ClassType ();
public static final NullableType SERIALIZABLE = new SerializableType (Serializable.class);
public static final Type OBJECT = new AnyType ();
没有评论:
发表评论