Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify Foo.class in scala?

Tags:

java

scala

I am using java API that looks like:

import com.google.code.morphia.Morphia;

.....

     val morphia = new Morphia();
     morphia.map(Hotel.class).map(Address.class);

but it gives scala compiler error. what is the correct code in scala for above? Note that .map is defined as part of morphia API and not to be confused with scala map.

like image 828
ace Avatar asked Dec 21 '22 12:12

ace


2 Answers

Assuming your problem is with the .class parts, the Scala equivalent of Hotel.class would be classOf[Hotel], likewise for Address.

Hopefully this should fix your problem, although it's hard to tell without seeing the full compiler output.

like image 92
prat_c Avatar answered Dec 24 '22 00:12

prat_c


You should use classOf[Hotel]

like image 20
Knut Arne Vedaa Avatar answered Dec 24 '22 00:12

Knut Arne Vedaa