You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to copy & paste the example code, from the README and only changed the db credentials.
I get the following error:
../../.dub/packages/hunt-validation-0.1.1/hunt-validation/source/hunt/validation/DeclDef.d-mixin-40(42,52): Error: function `app.User.MakeModel!().MakeValid!().valid` does not override any function
../../.dub/packages/hunt-entity-2.3.4/hunt-entity/source/hunt/entity/Entity.d(25,5): Error: mixin `app.User.MakeModel!().MakeValid!()` error instantiating
source/app.d(6,5): Error: mixin `app.User.MakeModel!()` error instantiating
I already tried to find the reason for this error on my own but I just started learning d-lang an hour ago so i'm not that experienced enough to really understand that error.
The text was updated successfully, but these errors were encountered:
I just hit the same problem and found this issue via google.. from looking at the examples in the examples/ directory it looks like the User class needs to extend hunt.entity.Model
so the class should look like this, adding : Model to the declaration:
@Table("user")
classUser : Model
{
mixin MakeModel;
...
}
After fixing that I'm still unable to compile however.. dub build tells me that there's no log(...) function. But after including hunt.logging I can find logDebug() which seems to work.
So here's my modified source that compiles successfully:
import hunt.entity;
import hunt.logging;
@Table("user")
classUser : Model
{
mixin MakeModel;
@PrimaryKey
@AutoIncrement
int id;
string name;
double money;
string email;
bool status;
}
voidmain()
{
auto option = new EntityOption;
option.database.driver = "postgresql";
option.database.host = "...";
option.database.port = 5432;
option.database.database = "...";
option.database.username = "...";
option.database.password = "...";
option.database.prefix = "hunttest_";
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("postgresql", option);
EntityManager em = entityManagerFactory.createEntityManager();
// begin transaction
em.getTransaction().begin();
// define your database existing row id in hereint id = 1;
auto user = em.find!User(id);
logDebug("User name is: ", user.name);
// commit transaction
em.getTransaction().commit();
em.close();
entityManagerFactory.close();
}
I tried to copy & paste the example code, from the README and only changed the db credentials.
I get the following error:
My dub.json:
My dmd version is: v2.085.1
I already tried to find the reason for this error on my own but I just started learning d-lang an hour ago so i'm not that experienced enough to really understand that error.
The text was updated successfully, but these errors were encountered: