Announcement Announcement Module
Collapse
No announcement yet.
Quick Question - how can I make this type safe? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quick Question - how can I make this type safe?

    How can I make this type safe?

    Code:
    	public List<Module> findAllWithAdmin( long adminId ) {
    		return (List<Module>) sessionFactory.getCurrentSession().createQuery(
    			"from Module module where module.admin.id = :adminId" )
    			.setParameter( "adminId", adminId )
    			.list();
    	}
    Last edited by mystic; May 10th, 2009, 02:02 AM.

  • #2
    Clarify which part you think is not "type safe"?

    ("from Module ...").list() will return a List<Module>
    so it is "type safe" although the Java compiler cannot prove this.

    If you want to stop the compiler from barking, consider
    @SuppressWarnings("unchecked")

    Comment

    Working...
    X