小编Jam*_*urn的帖子

扩展Laravel中的雄辩模型(使用不同的表)

我正在构建一个涉及跟踪不同类型潜在客户的Laravel应用程序.例如,有再融资线索购买线索.

由于引线共享大量的信息和功能,但不是全部,我的想法是创建一个Lead类,它扩展了Laravel的Model类,然后是一个RefinanceLead扩展Lead类的类.

所以我有:

class Lead extends Model
{
    // shared lead stuff
}

class RefinanceLead extends Lead
{
    // stuff specific to refinance leads
}
Run Code Online (Sandbox Code Playgroud)

我的问题是:

  1. 这种策略有意义吗?
  2. 如果是这样,Eloquent将如何处理数据?我有leads桌子和refinance_leads桌子吗?
  3. RefinanceLead类的新实例是否会使用leads表中的任何内容?

我在通过文档回答这个问题时遇到了麻烦,但是如果我错过了解释的地方,请告诉我.谢谢.

inheritance models laravel eloquent

11
推荐指数
1
解决办法
1万
查看次数

org.hibernate.hql.ast.QuerySyntaxException:表未映射

我知道很多人都问过这个问题,但我刚开始使用Java,所以我还是想不通.

所以这是我的问题:我正在使用RESTful webservices Javarestlet.这是我的DAO文件的片段.

try {

            session.beginTransaction();

            String query = "select number from   blockedcli";
            @SuppressWarnings("rawtypes")
            List list = session.createQuery(query).list(); //.setString("sId", businessId)


            logger.error("*******************list*****************************************");
            logger.error(list);
            logger.error("*******************listend*****************************************");


            @SuppressWarnings("rawtypes")
            Iterator iterator = list.iterator();

            while (iterator.hasNext()) {

                blockedcli = (BlockedCli) iterator.next();
            }
            session.getTransaction().commit();
        } 
Run Code Online (Sandbox Code Playgroud)

相应地,我的实体类看起来像.

@Entity
@Table(name = "blockedcli")
public class BlockedCli implements Serializable{

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="idBlockedCLI", nullable = false, unique=true)
    private Integer idBlockedCLI;

    @Column(name = "number",nullable = false, length=45)
    private String number;

    @Column(name = …
Run Code Online (Sandbox Code Playgroud)

java hibernate restlet-2.0

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

eloquent ×1

hibernate ×1

inheritance ×1

java ×1

laravel ×1

models ×1

restlet-2.0 ×1