Hibernate代码生成:org.hibernate.HibernateException:当没有连接可用时,必须设置'hibernate.dialect'

时间:2015-12-03 09:01:22

标签: eclipse hibernate code-generation dialect

尝试在Eclipse Mars中使用Hibernate Tool Code时,我遇到了这个问题。我已经在我的NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path1 = [NSString stringWithFormat:@"%@/firstPart.caf",documentsDirectory]; NSString *path2 = [NSString stringWithFormat:@"%@/New-Recording.caf",documentsDirectory]; AVAsset *avAsset1 = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:path1] options:nil]; AVAsset *avAsset2 = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:path2] options:nil]; AVMutableComposition *composition = [[AVMutableComposition alloc] init]; // [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; AVMutableCompositionTrack *track = [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; AVAssetTrack *assetTrack1; AVAssetTrack *assetTrack2; if ([avAsset1 tracksWithMediaType:AVMediaTypeAudio].count > 0) { assetTrack1 = [[avAsset1 tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]; assetTrack2 = [[avAsset2 tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]; } NSError *error; CMTime insertionPoint = kCMTimeZero; [track insertTimeRange:CMTimeRangeMake(kCMTimeZero, avAsset1.duration) ofTrack:assetTrack1 atTime:insertionPoint error:nil]; insertionPoint = CMTimeAdd(insertionPoint, avAsset1.duration); [track insertTimeRange:CMTimeRangeMake(kCMTimeZero, avAsset2.duration) ofTrack:assetTrack2 atTime:insertionPoint error:nil]; NSURL *outPutUrl = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/mergedFilePart1.caf",documentsDirectory]]; AVAssetExportSession *exportSession = [AVAssetExportSession exportSessionWithAsset:composition presetName:AVAssetExportPresetAppleM4A]; exportSession.outputURL = outPutUrl; exportSession.outputFileType = AVFileTypeAppleM4A; [exportSession exportAsynchronouslyWithCompletionHandler:^{ if (AVAssetExportSessionStatusCompleted == exportSession.status) { NSLog(@"AVAssetExportSessionStatusCompleted"); [self mergeAudioPart2]; } else if (AVAssetExportSessionStatusFailed == exportSession.status) { NSLog(@"%ld",(long)exportSession.status); NSLog(@"AVAssetExportSessionStatusFailed"); } else { NSLog(@"Export Session Status: %ld", (long)exportSession.status); } }]; 中添加了方言,包括hibernate.cfg.xml

  

org.hibernate.HibernateException:'hibernate.dialect'       此处输入代码必须在没有连接可用时设置


hibernate.cfg.xml中

sqljdbc4.jar


hibernate.reveng.xml中

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                         "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
 <session-factory name="">
  <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
  <property name="hibernate.connection.password">123</property>
  <property name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;databaseName=Qlsach</property>
  <property name="hibernate.connection.username">sa</property>
  <property name="hibernate.show_sql">true</property>
  <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
 </session-factory>
</hibernate-configuration>

1 个答案:

答案 0 :(得分:0)

我通过在&#34; Main&#34;中将Hibernate版本从5.1更改为4.3来解决了这个问题。 Hibernate配置对话框的选项卡。